SettingsHow-to
How to keep your Mac awake: settings, Terminal and a menu bar switch
Short answer
To keep a Mac awake for a while, run caffeinate -d in Terminal and leave the window open, or use a menu bar switch such as Cruise Control. To stop it sleeping for good, set System Settings › Lock Screen › Turn display off when inactive to Never, then turn on Prevent automatic sleeping when the display is off (in Battery › Options on a MacBook, or Energy on a desktop Mac).
On this page
- Keep it awake for a while with Terminal
- Keep it awake from the menu bar
- Stop a MacBook from sleeping on its own
- Stop a desktop Mac from sleeping
- Stop the Mac sleeping during a download
- What keeping it awake doesn't stop
- Check what's keeping your Mac awake
- Apps that keep a Mac awake
- Sources and further reading
Keep it awake for a while with Terminal
macOS has a built-in command for this, caffeinate. It keeps the Mac awake for as long as it runs.
- Open Terminal (in Applications › Utilities, or press Command-Space and type Terminal).
- Type
caffeinate -dand press Return. The Mac and its screen now stay awake. - Leave the Terminal window open. To let the Mac sleep again, press Control-C or close the window.
A few useful variations:
| Command | What it does |
|---|---|
caffeinate -d | Keeps the Mac and the screen awake. |
caffeinate -i | Keeps the Mac awake but lets the screen turn off. Good for downloads and backups. |
caffeinate -d -t 3600 | Stays on for 3600 seconds (one hour), then stops on its own. |
caffeinate -i some-command | Keeps the Mac awake until that command finishes, for example a long script or curl download. |
caffeinate -i -w 1234 | Keeps the Mac awake until the process with ID 1234 quits. Find the ID in Activity Monitor. |
Keep it awake from the menu bar
If you'd rather not keep a Terminal window around, a menu bar app does the same thing behind a click. They use the same mechanism as caffeinate, and macOS forgets the request as soon as the app quits.
Stop a MacBook from sleeping on its own
A MacBook sleeps after its display turns off. Keep the display on longer, or let the Mac stay awake while it's off:
- Open System Settings › Lock Screen.
- Set Turn display off on power adapter when inactive to Never, or to a longer time. Do the same for the battery setting if you want.
- To keep the Mac working with the screen off instead, open System Settings › Battery, click Options, and turn on Prevent automatic sleeping on power adapter when the display is off.
This only applies while the charger is connected. On battery, the Mac still sleeps once the display turns off, and it always sleeps when you close the lid. For that, see keeping a MacBook awake with the lid closed.
Stop a desktop Mac from sleeping
On an iMac, Mac mini, Mac Studio or Mac Pro:
- Open System Settings › Energy (called Energy Saver on older versions).
- Turn on Prevent automatic sleeping when the display is off.
- To keep the screen on too, open System Settings › Lock Screen and set Turn display off when inactive to Never.
Stop the Mac sleeping during a download
When a Mac goes to sleep, most downloads pause, and some don't pick up again when it wakes. For one big download, you don't need to change any settings:
- Plug in the charger and leave the lid open.
- Run
caffeinate -iin Terminal, or turn on a keep-awake app. The screen can still turn off, and the download keeps going. - When the download is done, press Control-C in Terminal or switch the app off, so the Mac sleeps as usual again.
For a download from Terminal, put caffeinate -i in front of the command, such as caffeinate -i curl -O https://example.com/big-file.zip, and the Mac stays awake exactly until it's done. If a macOS update won't finish downloading, see fixes for macOS updates that won't download.
What keeping it awake doesn't stop
- Closing the lid. A MacBook sleeps when you close it, unless it's in clamshell mode with an external display. See the lid-closed guide.
- Sleep from the Apple menu, or pressing the power button.
- A nearly empty battery. macOS puts the Mac to sleep to protect your work.
Check what's keeping your Mac awake
If your Mac won't sleep, or sleeps when it shouldn't, run pmset -g assertions in Terminal. Lines with PreventUserIdleSystemSleep or PreventUserIdleDisplaySleep set to 1 mean something is holding the Mac awake, and the list below them names the app, such as a video player, a call or caffeinate itself.
Apps that keep a Mac awake
They all do what caffeinate does, behind a switch in the menu bar. Pick the one with the options you need.
| App | What it does | Price |
|---|---|---|
| Cruise Control Made by us | A keep-awake switch with a timer, Let the screen dim, and lid-closed awake | Free |
| Amphetamine | Keep-awake sessions with triggers for apps, downloads, displays and more | Free |
| KeepingYouAwake | A minimal menu bar toggle built on caffeinate | Free, open source |
Sources and further reading
- caffeinate man page · SS64
- pmset man page · SS64
Applies tomacOS 27TahoeSequoiaSonoma
Reader tips
No tips yet. If something else worked for you, or a step looks different on your Mac, add it here.