Do you need your Mac to keep running, no matter what? You might want to make sure that if your computer crashes or there’s a brief power outage in your area and you aren’t near your Mac, it restarts on its own.
With a simple Terminal command or flip of a switch in System Settings, you can make your Mac automatically restart after a crash or power failure, and this tutorial shows you how to do that.
Terminal command to automatically restart your Mac
Open Terminal, enter the following Terminal command into the window, and then hit Return.
sudo systemsetup -setrestartfreeze on
Enter your password, hit Return once more, and that’s it. You should never have to enter this command again.
To turn off the automatic restart, use the following command.
sudo systemsetup -setrestartfreeze off
And to check the status of your automatic restart, enter this command.
sudo systemsetup -getrestartfreeze
Use System Settings
You can set your Mac desktop, like Mac mini, to turn on automatically after a power outage. Here’s how:
- Open System Settings and select Energy Saver.
- Turn on the switch for ‘Start up automatically after a power failure.’
Extra info: With certain UPS models that plug into Mac’s USB port, you can set when your Mac shuts down while using UPS power.
Terminal commands to keep your Mac on
Let’s say you want to keep your Mac on for a certain amount of time without going to sleep, for instance. Instead of opening System Settings or System Preferences and making changes in Energy Saver, just use the following command.
caffeinate -t [seconds]
So, if you want your Mac to stay on for, say, an hour, enter the number of seconds for one hour:
caffeinate -t 3600
You can also use the following command to keep your Mac on permanently as long as the Terminal is running:
To stop a “caffeinate” command, use the keyboard shortcut Control + C in the Terminal window.
Having your Mac restart automatically after a crash or keeping it on when you need it most are both easy to do with simple Terminal commands.
Let us know in the comments below if you plan to use the automatic restart command for your Mac.
Check out next: