Guide · macOS
How to keep your Mac awake
Two tools come with macOS: the sleep settings in System Settings, and the caffeinate command in Terminal. Use the settings for a change that lasts. Use caffeinate for one job, like a long download or build.
Which one to use
| You want | Use |
|---|---|
| The screen to stay on longer, every day | System Settings › Lock Screen › "Turn display off on battery when inactive" and "Turn display off on power adapter when inactive" |
| The Mac to keep working after the display turns off, every day | MacBook: System Settings › Battery › Options › "Prevent automatic sleeping on power adapter when the display is off." Desktop Mac: System Settings › Energy › "Prevent automatic sleeping when the display is off." |
| The screen on and the Mac awake for a set time | caffeinate -d -i -t <seconds> |
| The Mac awake until a job finishes | caffeinate -i <command> or caffeinate -i -w <PID> |
| The Mac awake with the lid closed | An external display, power, and an external keyboard and mouse (Apple) |
Sources: Apple's guides to sleep and wake settings and Lock Screen settings.
Use caffeinate for one job
From man caffeinate:
-dkeeps the display from sleeping.-ikeeps the Mac from idle sleep. This is the default when you give no option.-skeeps the Mac from sleeping at all, but only on power adapter.-t 3600stops after 3,600 seconds.-w 1234stops when the process with ID 1234 exits.
caffeinate -d -i -t 7200 # display and Mac awake for 2 hours
caffeinate -i ./long-build.sh # Mac awake until the script finishes
caffeinate -i -w 1234 # Mac awake until process 1234 exits
Press ⌃C to stop early. To see what's keeping your Mac awake, run pmset -g assertions.
On macOS 27.0, caffeinate -d -i kept the display on for 2½ minutes after locking, compared with about 30 seconds without it. More in how to lock your Mac without turning off the screen.
Staying awake isn't the same as looking active. caffeinate and the settings above don't type or move the pointer.
If you don't want your screen sitting open
caffeinate and the settings above leave your screen visible to anyone walking by.
Dimma Screen is a menu bar app for this case. Choose Turn On and Keep Awake for 30 minutes, 1 hour, 2 hours, or 4 hours. The display stays lit, the Mac stays awake, and every display is covered. Any key or click asks for your 4- to 8-digit PIN, your login password, or Touch ID.
By default the cover is a faint tint, so you can watch a download finish from across the room. To hide the screen, choose Solid Color or Custom Image in Settings.
pmset -g assertionslists a display-sleep assertion named Dimma while the cover is on.- When the time is up, the cover stays and your Mac follows its energy settings again.
- To go to the macOS lock screen when the time is up, turn on Lock Screen When Keep Awake Ends in Settings.
Dimma Screen · macOS 26 Tahoe or later · Apple silicon · Free for 3 days, then $9.90 once. No subscription.
Limits
- Not a general keep-awake tool. It keeps your Mac awake only while the cover is on.
- Stops at 4 hours. For overnight jobs, use
caffeinate -iorcaffeinate -s. - It doesn’t move the pointer or press keys. macOS keeps counting idle time.
- Not a security lock. Where you need real security, press ⌃⌘Q.
Questions
Is there a free, built-in way to keep my Mac awake?
Yes. In Terminal, run caffeinate -d -i to keep the display and the Mac awake until you press Control-C. Add -t <seconds> to set a time limit. For a change that lasts, use the sleep settings in System Settings.
How do I stop my Mac from sleeping when the display turns off?
On a MacBook, open System Settings › Battery › Options and turn on "Prevent automatic sleeping on power adapter when the display is off." On a desktop Mac, open System Settings › Energy and turn on "Prevent automatic sleeping when the display is off."
How do I keep my Mac's screen on longer?
Open System Settings › Lock Screen and choose a longer time for "Turn display off on battery when inactive" and "Turn display off on power adapter when inactive." For one session only, run caffeinate -d in Terminal.
Can I keep my MacBook awake with the lid closed?
Yes, with an external display connected. The Mac must also be on power and use an external keyboard and mouse. Otherwise, closing the lid puts it to sleep.