Close ad

Have you ever found yourself in a situation where you wanted to set your Mac to shut down after a certain amount of time? If so, then you probably had to download some third-party app that made this option available to you. But did you know that you can set your Mac to shut down, restart, or sleep after a certain period of time, even without a third-party application, simply using the Terminal? If you want to know how to do it, then read this article to the end.

How to use Terminal to shut down a Mac after a certain amount of time

As I mentioned in the title and introduction, this whole process will take place in Terminal. You can find it either in Applications in the folder utilities, or you can run it with Spotlight (Command + Spacebar or magnifying glass at the top right of the screen). After starting the Terminal, a small window will appear in which you can enter various commands. If you want to turn off your Mac or MacBook after a certain period of time, do so copy it this command:

sudo shutdown -h +[time]

Then it to the Terminal insert Now it is necessary for you to choose a time v minutes, after which the Mac should be turned off. So in the command replace [time] minutes, after which the Mac should be turned off. If you want to shut down your Mac after 15 minutes, then the command will look like this:

sudo shutdown -h +15

Then don't forget to confirm the command with the key Enter.

Restart and sleep

In addition to the fact that you can set the shutdown of your Mac or MacBook, you can also set it restart whether falling asleep after a certain time. In case you want your macOS device after a certain period of time restart, so take advantage command below. Again, don't forget the command part [time] change to time in minutes, after which the restart should occur.

sudo shutdown -r +[time]

It works the same way if you want your apple computer moved to sleep mode. Just use it command, which I am attaching below. Even in this case, swap part of the command [time] za time in minutes, after which the device should go into sleep mode.

sudo shutdown -s +[time]
.