How to keep your Mac awake without changing its sleep settings
Open Terminal and run caffeinate -i. The Mac stays awake until you press Control-C or close the window; caffeinate -i -t 3600 stops by itself after an hour, and adding -d keeps the screen on too. If you want it to stay awake for days, Mac laptops have Prevent automatic sleeping on power adapter when the display is off in System Settings › Battery › Options (desktops: Energy). SleepPilot does the same from the menu bar and can turn itself off when a command, a download or a backup finishes.
Updated · commands checked on macOS 27.2
For a while: caffeinate
Built into macOS, free, and it changes no settings: it only holds the Mac awake while it runs.
- Open Terminal from Applications › Utilities.
- Type
caffeinate -i -t 3600and press Return. The Mac stays awake for 3600 seconds (one hour). Leave out-t 3600to keep it awake until you stop it. - The Mac stays awake while the command runs. The display can still turn off; add
-dif you want the screen on too. - Press Control-C in that window, or close the window. The Mac goes back to its normal sleep schedule.
caffeinate -i -t 3600
To check it’s working, run pmset -g in another window. On our Mac the sleep line then read (shortened):
sleep 1 (sleep prevented by bluetoothd, caffeinate, powerd, cameracaptured, Claude, coreaudiod, coreaudiod)
More flags and examples, including keeping the Mac awake until a particular command finishes: the caffeinate command.
For days: System Settings
If the Mac should never sleep on its own while it’s plugged in, for example because it shares files or runs a server, change the setting instead.
- On a Mac laptop, choose Apple menu › System Settings, click Battery, then click Options.
- Turn on Prevent automatic sleeping on power adapter when the display is off. On a desktop Mac, the setting is Prevent automatic sleeping when the display is off in Energy.
- It stays on until you turn it off again. Apple notes that preventing sleep can increase power consumption.
How soon the screen turns off is a separate setting: System Settings › Lock Screen › Turn display off on battery when inactive and Turn display off on power adapter when inactive.
Some options aren’t available on every Mac, Apple says.
From the menu bar: SleepPilot
SleepPilot (Mac App Store) puts a moon in the menu bar. Click it and choose how long to keep the Mac awake: Until I stop, 30 minutes, 1 hour or 3 hours. Keep the display on decides whether the screen stays lit or goes dark while the Mac keeps working. Control-Option-S turns it on and off from any app.
Until done… waits for a job instead of a clock: a command running in Terminal, a file still downloading into Downloads, or a Time Machine backup. When it finishes, SleepPilot lets the Mac sleep as usual and sends a notification. It also lets go when the battery drops to a level you choose, or if the Mac gets critically hot.
Which one to use
| Method | Stops by itself | Good for |
|---|---|---|
caffeinate -i -t 3600 | After the time you set | A known stretch of time |
caffeinate -i + a command | When the command ends | Builds, encodes, AI agents |
| Battery or Energy setting | No, until you turn it off | A Mac that should stay on |
| SleepPilot | After a time, or when a command, download or backup ends | Not having to remember |
None of them keeps a MacBook awake with the lid closed, unless it’s in Apple’s closed-display mode.
Questions
Does keeping the Mac awake keep the screen on?
Not with caffeinate -i: the Mac stays awake and the display turns off on its usual timer. Use caffeinate -d -i to keep both on. In SleepPilot, it’s the Keep the display on option.
Will my MacBook stay awake with the lid closed?
No. Closing the lid puts it to sleep unless it’s in closed-display mode with power, an external display, keyboard and mouse. Lid closed: what works.
Does caffeinate need an administrator password?
No. We ran every command on this page as a normal user, without sudo.
Can I still put the Mac to sleep myself?
Yes. Apple’s power-management header says that while an app prevents idle sleep, the Mac can still sleep when you close the lid, choose Sleep from the Apple menu, or the battery runs low.
How do I know it worked?
Run pmset -g. While caffeinate runs, the sleep line includes “sleep prevented by … caffeinate”.
Sources
- Set sleep and wake settings for your Mac — Apple Support
- Change Battery settings on a Mac laptop — Apple Support
- caffeinate(8) man page
- IOPMLib.h: power assertion types — Apple open source