James Pearson

October 12, 2021

Terminal Hacks - Caffeinate your Mac

If you need to run a process on your Mac that cannot be interrupted by the Mac's sleep cycle, such as running a task in Automator or downloading a large amount of data, then you can caffeinate the Mac to keep it awake. Here's how...

LECTROHACK-#4-artwork.jpg


Caffeinate (no time limit)


Open Terminal: Finder > Applications > Utilities

In Terminal, type or paste the following…

caffeinate

(return)


-


Caffeinate (time limited)


Open Terminal: Finder > Applications > Utilities

In Terminal, type or paste the following…

caffeinate -u -t 3600

(return)

The numerical value at the end of the command represents the amount of seconds you wish to keep your Mac awake for.

After executing the command the caffeinate cycle will prevent your Mac from sleeping during that specified time period so long as you don't close or quit Terminal.

::TIP:: 3600 seconds = 1 hour


You can end the caffeinate cycle at any point by pressing Control + C on your keyboard whilst in Terminal. Alternatively, you can close or quit the Terminal application.

Once the caffeinate command is terminated the Mac will resume its usual sleep cycle as defined by your Energy Saver settings (in System Preferences).