caffeinate on Mac: Keep Your Mac Awake From Terminal
caffeinate is the built-in macOS command that keeps a Mac awake. Run caffeinate -d to stop the display sleeping, -i to stop idle sleep, add -t for a time limit, and press Ctrl+C to stop. Every flag with examples, and why awake is not active in Slack.
On this page
The caffeinate command keeps a Mac awake from Terminal: run caffeinate -d to keep the display on, or plain caffeinate to block idle sleep, and press Ctrl+C to stop it.
Add -t 3600 to stop after an hour, or put a command after it, such as caffeinate -i ./backup.sh, to stay awake only while that command runs. It is built into macOS, needs no admin password and no install.
It does not keep Slack active. The Slack desktop app sets you away 10 minutes after your last keyboard or mouse input on the Mac, whether the Mac is awake or not (Slack desktop 4.52.178 code, checked 7 Oct 2026). caffeinate only stops the instant away you get when the Mac sleeps.
We ran every command on this page on a MacBook with macOS 26.5.2 (Apple silicon) on 30 September 2026, and checked each one with pmset -g assertions. The output is below.
caffeinate flags
The meanings come from man caffeinate. The last column is the assertion each flag created on our Mac, as pmset -g assertions listed it.
| Flag | What it does | Assertion we saw |
|---|---|---|
-d | Prevents the display from sleeping | PreventUserIdleDisplaySleep |
-i | Prevents the system from idle sleeping | PreventUserIdleSystemSleep |
| none | Same as -i | PreventUserIdleSystemSleep |
-m | Prevents the disk from idle sleeping | PreventDiskIdle |
-s | Prevents the system from sleeping, only on AC power | PreventSystemSleep |
-u | Declares that the user is active and turns the display on. Lasts 5 seconds unless you add -t | UserIsActive |
-t seconds | Drops the assertion after that many seconds | "caffeinate asserting for 20 secs" |
-w PID | Keeps it until the process with that ID exits | "asserting on behalf of Process ID 97977" |
command | Keeps it while the command runs | none extra |
Three traps we found on 7 October on the same Mac. -t reads whole seconds only, so caffeinate -t 2h ran for 2.1 seconds with no error. -u without -t takes -m with it after 5 seconds, so caffeinate -dimsu held 3 of its 5 assertions from then on. And -t in front of a command lets go at that time even while the command still runs. The caffeinate command builder checks any line for these and writes one for a time, a clock time or an app.
What pmset showed on our Mac
This is caffeinate -dims -t 20 running, one second in:
$ caffeinate -dims -t 20 &
$ pmset -g assertions | grep caffeinate
pid 97573(caffeinate): [0x0001aacb000197db] 00:00:01 PreventUserIdleSystemSleep named: "caffeinate command-line tool"
Details: caffeinate asserting for 20 secs
pid 97573(caffeinate): [0x0001aacb000597dc] 00:00:01 PreventUserIdleDisplaySleep named: "caffeinate command-line tool"
Details: caffeinate asserting for 20 secs
pid 97573(caffeinate): [0x0001aacb000797dd] 00:00:01 PreventSystemSleep named: "caffeinate command-line tool"
Details: caffeinate asserting for 20 secs
pid 97573(caffeinate): [0x0001aacb000f97de] 00:00:01 PreventDiskIdle named: "caffeinate command-line tool"
Details: caffeinate asserting for 20 secs
The timed runs ended on their own. caffeinate -t 2 returned after 2.10 seconds, and caffeinate -i sleep 3 after 3.01 seconds, the length of the command it wrapped. With -w, caffeinate exited as soon as the process it watched ended. After caffeinate -u -t 3 finished, pmset -g assertions | grep -c caffeinate printed 0, so nothing is left behind. None of it asked for a password; it ran as our normal user.
caffeinate -i vs -d
- •
caffeinate -ikeeps the computer running, but the display can still turn off. Use it for downloads, backups and builds. - •
caffeinate -dkeeps the display on. Use it when you want the screen visible, or to stop the screen saver and the lock that follows it. - •
caffeinate -didoes both. Flags combine, socaffeinate -dimssets four at once.
For a permanent change instead of a running command, see how to turn off the screen saver on a Mac.
caffeinate examples
# Keep the display on until you press Ctrl+C
caffeinate -d
# Keep the Mac awake for two hours, then stop
caffeinate -di -t 7200
# Stay awake only while a command runs
caffeinate -i rsync -a ~/Projects /Volumes/Backup/
# Stay awake until another app quits (find its PID with pgrep)
caffeinate -i -w "$(pgrep -x Transmission)"
# Run it in the background and keep using the same Terminal window
caffeinate -d &
Check that it is working with pmset -g assertions | grep caffeinate, as in the output above. Without the grep, the same command lists everything else that keeps a Mac awake; on our Mac that included the Amphetamine app and an Electron app. More in why is my Mac not going to sleep.
Never appear "away" on Slack again
Cloud-based. No downloads. Works 24/7 even when your laptop is off.
How to stop caffeinate
pgrep -l caffeinate to find its process ID and kill that ID. killall caffeinate also works, but it stops every caffeinate, including ones a script or another app started.-t, it stops on its own when the time is up.caffeinate and the MacBook lid
Closing the lid puts a MacBook to sleep even with caffeinate running, unless the Mac is on power with an external display, keyboard and mouse attached. caffeinate keeps an open Mac awake; it does not replace clamshell mode. With no display attached, the admin command pmset disablesleep keeps a closed Mac awake, until you set it back to 0. Lid-closed options for Mac and Windows are in keep a laptop awake with the lid closed.
Does caffeinate keep Slack active?
No. We tested the same thing with the Caffeine app: Slack stayed green until minute 10, then went away with the screen still on. The full test is in does Caffeine keep Slack active.
caffeinate removes one trigger, the Mac sleeping or locking, which sets you away at once. Slack's idle timer reads the Mac's idle time, and caffeinate creates no input. caffeinate -u wakes the display for a few seconds but does not reset the idle counter. The Mac-specific rules are in keep Slack active on Mac, and every method is compared in how to keep Slack active.
If you would rather click a menu bar icon than type a command, we compared Amphetamine, KeepingYouAwake, Caffeine, Lungo and KeepAwake in the best app to keep a Mac awake.
caffeinate on a work Mac
caffeinate is built in and needs no admin rights, so it works on most managed Macs. A screen lock enforced by your company through MDM still applies. Lock Screen settings that stop locks for good are in keep a Mac screen from locking. For Windows and Linux equivalents, see keep a work computer awake without admin rights.
FAQ
Does caffeinate need sudo?
No. It runs as your user. Every command on this page ran without a password.
Does caffeinate survive closing Terminal?
Closing a Terminal window sends a hangup signal to what runs in it. In our test that signal stopped a plain caffeinate at once, while one started with nohup caffeinate -t 60 & kept running. Use nohup if you want to close the window.
Stop Jiggling Your Mouse.
Join hundreds of remote workers who never worry about their Slack status. Set it up once, stay green forever.
Related Articles
How to See All Your DMs in Slack, Including the Hidden Ones
The DMs tab lists your direct messages with people. App DMs, Slackbot and DMs with deleted accounts sit elsewhere. We compared the tab with the full list the Slack API returned.
Slack Images Not Showing? 5 Causes We Reproduced
We uploaded images to a Slack test channel and then switched each image setting off, ran /collapse, and posted from a bot that was not in the channel. Five causes, each reproduced.
How to Message Yourself on Slack (and What It Notifies)
Your own name under Direct messages opens a private DM with yourself. We sent it a note, a file, a scheduled message and a reminder, and checked which ones raised a badge.