Skip to content

How to keep a Mac awake with caffeinate, and how to tell when something is using it

caffeinate keeps a Mac awake from Terminal, for a set time or while a command runs. Our Mac had it holding off sleep for a tool. The flags and how to spot it.

4 min read

How do I keep a Mac awake with caffeinate?

CommandWhat it does
caffeinateKeeps the Mac awake until you press Control C
caffeinate -i -t 3600Stops idle sleep for one hour
caffeinate -dKeeps the display on too
caffeinate -i -w 1234Stays awake until process 1234 exits
caffeinate -i makeStays awake while make runs

-i prevents idle sleep, -d display sleep, -s system sleep while on power, -t sets seconds. Closing the lid still sleeps a MacBook without an external display.

How do I know if caffeinate is keeping my Mac awake?

pmset -g assertions | grep -i caffeinate

On our Mac it showed caffeinate asserting for 300 secs, a tool keeping the Mac awake in five minute steps, and pmset -g listed sleep as prevented by caffeinate. Quitting the tool, or killall caffeinate, lets the Mac sleep again.

See it live

Free Mac's System tab shows what the Mac is drawing from the adapter and the battery, and ranks what is draining it by energy impact, every second. See also what is preventing your Mac from sleeping.

Related: pmset: change Mac sleep settings in Terminal and Does Power Nap drain a Mac's battery.

Common questions

How do I keep my Mac awake with Terminal?

Run caffeinate -i. Add -t 3600 for one hour, or -w and a process ID to stay awake until it ends.

Does caffeinate work with the lid closed?

Not on a MacBook without an external display and power. Closing the lid still sleeps it.

How do I stop caffeinate?

Press Control C in its window, or run killall caffeinate.

Read next