How to stop your Mac from sleeping: the settings, the command and the app

Stop a MacBook or desktop Mac from sleeping in System Settings, keep it awake just for a while with caffeinate, or tie it to a task. No mouse jiggling.

To stop a Mac from sleeping, open System Settings. On a MacBook, go to Battery > Options and turn on “Prevent automatic sleeping on power adapter when the display is off”. On a desktop Mac, the same switch is in Energy. Then, in Lock Screen, set how long the display waits before turning off. For a one-off, the caffeinate command or a menu bar app does it without touching your settings.

Two things that look the same: the display and the Mac

macOS treats them separately. The display turns off after some idle minutes, and that is harmless: downloads and apps keep running. The Mac going to sleep is what stops them. So the question is usually not “how do I keep the screen on” but “how do I keep the Mac working when the screen goes dark”. The settings below cover both.

On a MacBook

  1. Open System Settings > Battery and click Options.
  2. Turn on “Prevent automatic sleeping on power adapter when the display is off”. While it is plugged in, the Mac keeps working after the display turns off.
  3. Open System Settings > Lock Screen and pick a time for “Turn display off on power adapter when inactive” (and the battery one, if you want). Longer keeps the screen on longer.

On battery there is no switch that keeps a MacBook awake indefinitely, by design. And closing the lid puts it to sleep, unless it is plugged in with an external display (closed-lid mode).

On an iMac, Mac mini, Mac Studio or Mac Pro

  1. Open System Settings > Energy and turn on “Prevent automatic sleeping when the display is off”.
  2. In Lock Screen, pick a time for “Turn display off on power adapter when inactive”.

Apple notes that some of these options may not be there, depending on your Mac. If you do not see one, the rest of this page still applies.

Only for a while: caffeinate

The settings above stay on until you change them back. For “just during this download”, macOS includes caffeinate. In Terminal:

  • caffeinate -i keeps the Mac awake (the display can still turn off) until you press Control-C.
  • caffeinate -d keeps the display on as well.
  • caffeinate -i -t 7200 does it for two hours (the time is in seconds).
  • caffeinate -i ./backup.sh does it exactly while that command runs.

Every flag, with examples, is in our caffeinate guide.

One click: Keep Awake

Disclosure: this one is ours. Keep Awake is built into Webstarted Toolbox, a free menu bar app for macOS 12 and later (and Windows 10 and later). It uses caffeinate under the hood and lets go on its own, so your settings never change:

  • 30 minutes to 8 hours, any other length or a clock time with “Other…”, or until you turn it off.
  • “While a process runs”: give it a process name and the Mac stays awake while that process runs.
  • Turn the screens off after 5 to 30 idle minutes, optionally locking the session first, while the Mac keeps working.
  • “Only when plugged in”: on battery it stops holding the Mac awake until you plug in.

Which one to use

None of these move the mouse, so a chat app can still show you as away. Keeping the Mac awake is not the same as looking active.

Sources

Get Webstarted Toolbox

Keep Awake comes built into Toolbox: free, no account, macOS 12 and later and Windows 10 and later.

Free beta · macOS · Windows (x64) · Signed & notarized · No account required