0

Use a Terminal Command to Stop Your Mac From Sleeping

Posted by Jim Tanous on March 6, 2017
mac coffee

We generally want our Macs to sleep when not in use: saving battery life, reducing energy usage, and increasing the longevity of our Mac’s components. But sometimes we intentionally don’t want our Macs to sleep, such as when preparing to give a Keynote presentation or when you’re letting a colleague or family member use your Mac.
In these instances, you could go to System Preferences > Energy Saver and use the slider to tell your Mac to “never” sleep. But this isn’t ideal, as it both involves a few extra steps and you may forget to set it back when you’re done.
macbook energy saver preferences
Instead, there’s a built-in terminal command that can temporarily keep your Mac awake and prevent all sleep settings. This command is appropriately called caffeinate.

Keep Your Mac Awake via the Terminal

To use the caffeinate command, first launch the Terminal app, located by default in Applications > Utilities (you can also find Terminal by searching for it via Spotlight). At the Terminal prompt, enter the following command and press Return:

caffeinate

Nothing will appear to happen, but if you look closely you’ll see the Terminal cursor sitting on a blank line and you’ll notice that the Terminal status bar now says “caffeinate.” There’s no fancy user interface here, but this means that the command is working.
mac no sleep caffeinate
While the caffeinate command is running, everything will operate as normal on your Mac, except that it will not go to sleep regardless of your sleep settings in System Preferences. When you’re done with your presentation or whatever it was that you wanted your Mac to stay awake for, just click on Terminal to make the window active and use the keyboard shortcut Control-C. This will terminate the caffeinate command and your Mac will now sleep again according to your defined preferences.
mac no sleep caffeinate quit
As mentioned, the benefit of this approach is that it’s relatively quick to enable or disable, and it doesn’t mess with your sleep settings in System Preferences. This means that you don’t need to remember to reset your sleep preferences each time you give a presentation, for example, and you’ll never walk into your office one morning only to realize that your Mac didn’t sleep all night.

Related: How to Schedule Your Mac to Automatically Boot, Sleep, and Shut Down

There are third party solutions that offer the same ability to keep your Mac awake, but the Mac’s built-in terminal command is easy, simple, and free!

Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.