Prevent Your Mac from Going to Sleep with This Built-in Tool

Computers go to sleep as a way to save energy and prevent unnecessary wear on your hardware. On macOS you can fine-tune this feature in System Preferences > Energy Saver.

But there are times when you might want to prevent your Mac from sleeping, for example until a certain task is completed.  And changing the settings back and forth can be annoying.

There’s an easier way…

When it comes to preventing your Mac from going to sleep, most macOS users immediately think of an app. Of course, there’s always an app. There is Caffeine which is a free popular options, but there’s also paid options.

What some ( most? ) macOS users seem to don’t know, is that this functionality is built-in into macOS for the last six years or so. And it’s a command line program called caffeinate. What were the chances right?

Being a command line tool, depeding on how comfortable you are with using the terminal and/or understanding the OS’ filesystem, you might not use it at it’s full potential. But even a complete noob can take advantage of caffeinate , and completely eliminate the need to install yet another app which can also be a potential security risk.

NOTE: I’m not saying that any of the third party apps that prevent your Mac from going to sleep have security flaws, all I’m saying is that ANY app you install can be yet another security risk.

So let’s see how to use caffeinate…

To prevent your Mac from going to sleep using the built-in caffeinate app, all you have to do is to open up the Terminal, type caffeinate and press enter.


If you run the command by itself, you will prevent your Mac from going to sleep as long as the command is active.

ALSO READ HOW TO: Background and Foreground Processes

To stop it you will need to kill the process with ctrl+c while inside the Terminal.

You can also set a sleep timer to caffeinate. For example, if you want to prevent your Mac from going to sleep for an hour you will type in caffeinate -t 3600. Change the timer ( in this example is 3600 ) to whatever you need. Time is expressed in seconds.

You can also target a specific application. For example, you might want to prevent your Mac from going to sleep while you export a video. All you have to do is type caffeinate path_to_the_core_of_the_app.

To do this you will have to right click on the app inside the /Applications/ folder, and select Show Package Contents and drag-and-drop the core of the app inside the terminal to get its path ( so you don’t have to type it ). Hint: the core is usually located in /Contents/MacOS/.

For more fine-tunning, there’s some spcific flags that you can use with caffeinate.

  • -d will prevent the display from going to sleep
  • -i will prevent the system from idle sleeping
  • -m will prevent the disk from going to sleep
  • -s will prevent the machine from going to sleep when plugged in
  • -u replicates a currently active user



We don't think that using an adblocker = piracy. That's simply not true. We use and recommend uBlock Origin.

However, as a small non-corporate website, we would appreciate it if you'd consider whitelisting FSM in your adblock of choice.

Alternatively, consider donating using the options below....

Monero (XMR) 43GnqUNJrTi9QyL7kEH8vM8pgWGCE6bjv1FSRipeNMM4TTeNnUVsRBb6MfMpQYxtLE7ReonxVVSXz2rFCEdW5H11LC3x73b
Bitcoin (BTC) 1Hfuq77gKKFJeNcq4EP4dQK3yDRWrFEwJR
Bitcoin Cash (BCH) qzmdm6e6q5wf2p6sxz2mst7cenz60newwc5m4e9js8
Ether (ETH) 0x5f02869278C24A6579d3820f52AD15936D6F9d69
More content?  
Ads Blocker Image Powered by Code Help Pro

Congrats on using an adblocker. We mean it.

Please support us by disabling your AdBlocker or whitelist us.

Thank you! ❤️