Tip 138Keep Your Mac Wide Awake

If you need to leave your Mac unattended for a while but want to temporarily stop it going into sleep mode, open a Terminal window, and type the following:

 
caffeinate -di

For as long as the Terminal window is open and the command is still running, the computer won’t go to sleep through inactivity, and nor will the display. Technically you’re turning off idle sleep mode, which occurs when OS X detects the user hasn’t done anything for a while.

To end the wakefulness, switch back to the Terminal window and hit Control+C or simply close the Terminal window.

Rather than running caffeinate indefinitely, you can specify a time limit, although this must be specified in seconds. If you wanted your computer not to sleep ...

Get Mac Kung Fu, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.