caffeinate command builder

Build a macOS caffeinate command, or paste one to see what it really holds. Pick screen, Mac or disk, and for how long: a time, a clock time, while an app is open or while a command runs. Every check comes from runs on a real Mac, like -t 2h lasting 2 seconds.

$
Check a line people use:
What this line holds, second by second
-i Mac awake2 h-d Screen on2 h0 s5 s10 s2 hClosing this Terminal window ends every bar.
  • It runs in this Terminal window: Ctrl+C stops it, and so does closing the window.

Keep awake

How long

hmin= -t 7200. caffeinate counts in seconds.

When you close Terminal

Check that it runs

pmset -g assertions | grep -A1 caffeinate

# one caffeinate line per assertion, with its Details:
PreventUserIdleSystemSleep   caffeinate asserting for 7200 secs
PreventUserIdleDisplaySleep  caffeinate asserting for 7200 secs

Stop it

# Ctrl+C in its Terminal window, or from another one:
pkill -f "^caffeinate -di"

Keep it as a word you type

NameThen open a new Terminal window and type awake.
echo "alias awake='caffeinate -di -t 7200'" >> ~/.zshrc

caffeinate keeps the Mac awake, not Slack active. In our test Slack still went away 10 minutes after the last input in the Slack window with the screen on: does Caffeine keep Slack active.

How to build a caffeinate command

  1. Tick what should stay awake: -d keeps the screen on, -i keeps the Mac running, -m the disk, -s the Mac while on power, -u wakes the screen now. Or paste a line you found, and the boxes follow it.
  2. Pick how long: until you stop it, for hours and minutes, until a clock time, while an app is open, or while a command runs. Pick whether it should survive closing the Terminal window.
  3. Read the bars and the notes. Each bar is one thing caffeinate holds, and it ends where caffeinate lets go. Amber means it lets go sooner than the line suggests.
  4. Click Copy command, paste it in Terminal and press Return. Run the check line to see it in pmset -g assertions, and keep the stop line for later.

Frequently asked questions

What does caffeinate -dimsu do?

For 5 seconds, all five: screen on (-d), no idle sleep (-i), disk awake (-m), no sleep on power (-s), user active (-u). Then -u ends, because -u without -t lasts 5 seconds, and it takes -m with it. On our Mac (macOS 26.5.2, 7 October 2026) pmset -g assertions listed 5 caffeinate assertions at 1 second and 3 at 6 and 12 seconds; the process kept running. caffeinate -dims, or -dimsu with a -t, held all of its assertions.

How do I keep a Mac awake for 2 hours with caffeinate?

caffeinate -di -t 7200. -t counts seconds only. caffeinate -t 2h ran for 2.1 seconds in our test, and -t 3m for 3.2 seconds, with no error message: caffeinate reads the number and ignores the letter. -t 0 means no limit, and a negative -t ends it at once.

How do I stop caffeinate?

Press Ctrl+C in the Terminal window it runs in. From another window, pkill -f "^caffeinate -di" stops only the runs that start with those flags; killall caffeinate stops every caffeinate, including ones another app started. A run with -t, -w or a command stops by itself.

Does caffeinate keep running after I close Terminal?

Not if it runs in the window, and not with a plain & either. In our test, closing the shell (it gets a SIGHUP, as when a Terminal window closes) ended caffeinate -i and caffeinate -i &. caffeinate -i & disown, caffeinate -i &! and nohup caffeinate -i & kept running.

Does caffeinate keep Slack active?

No. It keeps the Mac and the screen awake, but Slack sets you away 10 minutes after your last input in the Slack window. -u does not count as input either: the macOS idle timer kept counting through caffeinate -u -t 2 in our test.

Related reading

Slack Green does one thing: it keeps your Slack presence dot green while you are actually working, so a quiet keyboard does not mark you away. Try it free.