What does caffeinate do on a Mac?

By Matyas Rathonyi. Published November 23, 2026. Guides

caffeinate is a built-in macOS Terminal command that keeps your Mac from sleeping for as long as it runs, with no sudo and no saved settings to change, but Apple's own documentation says your Mac can still sleep when you close the lid (and its -s flag only applies on AC power). If a job needs to keep running after you close your MacBook lid on battery or power, Clamshell for Mac keeps a closed Apple Silicon MacBook awake from the menu bar with no admin password and nothing to undo, for $9.99 once after a 7-day free trial.

Written by Matyas Rathonyi, the maker of Clamshell for Mac.

A terminal starts caffeinate -i -t 3600, then pmset -g assertions shows the caffeinate process holding PreventUserIdleSystemSleep, asserting for 3600 seconds. $ caffeinate -i -t 3600 $ pmset -g assertions caffeinate: PreventUserIdleSystemSleep asserting for 3600 secs
Silent, but visible.caffeinate prints nothing while it runs. pmset -g assertions shows the assertion it holds and how long it lasts. (Lines condensed from our run.)

What caffeinate does

/usr/bin/caffeinate ships with macOS, needs no install, and runs without sudo. Apple's caffeinate(8) manual describes it as "prevent the system from sleeping on behalf of a utility."

While running, caffeinate holds one or more power assertions in memory and prints nothing to Terminal. Per Apple's manual, those assertions end automatically when caffeinate exits, when its -t timer expires, or when the command you pass to it finishes.

Every caffeinate flag explained

Here is what each flag in man caffeinate does and the power assertion pmset -g assertions shows for it:

FlagWhat it stopsAssertionLimit
(none)Idle system sleep (same as -i)PreventUserIdleSystemSleepLid close can still sleep Mac
-dDisplay sleep and idle system sleepPreventUserIdleDisplaySleepLid close can still sleep display
-iIdle system sleep (display may dim)PreventUserIdleSystemSleepLid close can still sleep Mac
-mDisk idle sleepPreventDiskIdleSystem can still sleep
-sSystem sleep on AC powerPreventSystemSleepAC power only, not battery
-uWakes display, marks user activeUserIsActive5-second timeout without -t
-t secondsDrops assertion after N secondsSame, asserting for N secsIgnored when wrapping a command
-w PIDHolds until process ID exitsSame, asserting on behalf of Process ID NIgnored when wrapping a command

Four details are easy to miss:

To assemble a command with a picker, use the pmset and caffeinate command builder.

Ready-to-use caffeinate commands

Every command below runs without sudo:

Keep your Mac out of idle sleep until you stop it (bare, or with -i explicit):

caffeinate
caffeinate -i

Keep your Mac awake for 1 hour (3600 seconds) or 2 hours (7200 seconds):

caffeinate -i -t 3600
caffeinate -i -t 7200

Keep the screen lit as well (caffeinate -d alone also works):

caffeinate -di

Block system sleep on AC power:

caffeinate -s

Hold all four assertions at once (display, idle, disk, and AC system sleep):

caffeinate -dims

Wake the display and mark the user active for 5 seconds:

caffeinate -u

Keep your Mac awake only while one command runs (Apple's manual example; replace make with your command; caffeinate passes the command's exit code through):

caffeinate -i make

Wrap a chain of commands using sh -c '...' so caffeinate tracks the whole sequence:

caffeinate -i sh -c 'sleep 1 && echo step1 && sleep 1 && echo step2'

Wait until an already-running process ends (replace <PID> with the process ID):

caffeinate -i -w <PID>
Three bars. A -t 3600 hold ends when its timer runs out. A hold for a command ends when the command finishes. A bare caffeinate holds until you stop it. -t 3600 caffeinate -i make caffeinate Control-C
Three ways a hold ends. A timer runs out, the command it runs finishes, or you stop it. Per Apple's manual, the assertion goes with it.

How to check and stop caffeinate

Because caffeinate prints nothing while active, check it from another Terminal tab with:

pmset -g assertions | grep caffeinate

Each line prints the PID, assertion type, and whether caffeinate is asserting forever, counting down a timeout, or holding on behalf of a command or PID. See pmset -g explained to read the rest of the output.

To stop caffeinate and release its assertions immediately:

Where caffeinate stops: closing the lid

caffeinate is built to prevent idle sleep while your lid stays open. Apple's IOPMLib.h SDK header states for PreventUserIdleSystemSleep (bare caffeinate and -i): "The system may still sleep for lid close, Apple menu, low battery, or other sleep reasons." For PreventUserIdleDisplaySleep (-d), it notes: "the display may still sleep for other reasons, like a user closing a portable's lid or the machine sleeping."

What about caffeinate -s? Apple's manual limits -s to AC power: "This assertion is valid only when system is running on AC power." On battery, -s does not apply at all, and the manual says nothing about a closed lid.

The built-in closed-lid alternatives ask for extra hardware or admin access. Apple's closed-display mode requires a charger plus an external monitor, keyboard, and mouse. Running sudo pmset -a disablesleep 1 asks for an admin password and turns sleep off until you undo it by hand.

Why pay $9.99 once for Clamshell when caffeinate is free? caffeinate is built for an open lid and stops protecting you once you close the lid on battery, while Clamshell handles a closed lid on battery or power with no sudo, nothing to undo, and built-in heat and battery cut-offs.

Test it on your Mac before paying anything: Download free trial (free for 7 days, no card required; $9.99 once for 1 Mac or $19.99 for up to 3 Macs, with a 14-day money-back guarantee). For more on closing the lid, see does caffeinate work with a MacBook lid closed and how to keep a Mac running with the lid closed.

When caffeinate is the better pick

Frequently asked questions

What does caffeinate -i do?

caffeinate -i holds a PreventUserIdleSystemSleep assertion that blocks idle sleep while still letting the display dim and sleep. It lasts until you press Control-C, a -t timer expires, or the command or -w process finishes, so use it for lid-open terminal jobs.

What is caffeinate -dims?

caffeinate -dims combines -d (display sleep), -i (idle system sleep), -m (disk idle sleep), and -s (system sleep on AC power only) in one command. Use it on a plugged-in Mac with the lid open when you want the screen, disk, and system to stay awake together.

How do I caffeinate my Mac for 1 hour or 2 hours?

Run caffeinate -i -t 3600 for 1 hour or caffeinate -i -t 7200 for 2 hours, since -t takes seconds. Swap -i for -di if you also want the screen to stay lit.

How do I stop caffeinate on a Mac?

Press Control-C in the Terminal tab where caffeinate is running. If it is running in another tab or in the background, find its PID with pmset -g assertions | grep caffeinate and stop it with kill followed by that PID.

Does caffeinate work with the lid closed?

Not reliably for general use: Apple's SDK header says the Mac may still sleep for lid close under bare caffeinate and -i, and that the display still sleeps on lid close under -d, and Apple's manual limits -s to AC power. If you want a closed Apple Silicon MacBook to stay awake on battery or power without sudo, start Clamshell's 7-day free trial instead.

What is the difference between caffeinate and pmset?

caffeinate needs no sudo and releases its hold automatically when it exits, while modifying power settings with pmset requires root and saves changes until you revert them. Use caffeinate for temporary lid-open jobs, pmset -g explained to inspect power settings, and Clamshell if you want closed-lid awake control with no admin rights.

Related guides

Try Clamshell free for 7 days

Keep your Apple Silicon MacBook running with the lid closed, on battery or power, with no admin password, an always-on heat cut-off, and a 20% battery floor. Normal lid sleep returns when you disarm or quit.

Download free trial $9.99 once, no subscription

$9.99 for 1 Mac, $19.99 for up to 3 Macs. 7-day free trial with no card required and a 14-day money-back guarantee. Apple Silicon, macOS 14 or later, notarized by Apple. Also available via Homebrew or Setapp.

Sources checked November 23, 2026: macOS 27.2.1 caffeinate(8) manual (footer dated November 9, 2012), Apple's IOPMLib.h header from the macOS 27.0 SDK, and command checks run without sudo on macOS 27.2.1. Clamshell details come from version 2.0.5. Clamshell is an independent app, not affiliated with or endorsed by Apple. Product names belong to their respective owners.