caffeinate -dimsu meaning: what each flag does on Mac
What caffeinate -dimsu means flag by flag (d, i, m, s, u), which flags you need, and which ones Glowmoth's menu bar app and CLI can replace.
Updated 6 min read
On this page
You found caffeinate -dimsu pasted as the answer to "how do I keep my Mac awake" and you want to know what the "imsu" part is for. Fair question: it is a stack of five flags, and most people need one or two of them.
What each flag in caffeinate -dimsu does
caffeinate ships with macOS, so there is nothing to install. Run it in Terminal and leave the window open:
caffeinate -dimsuIt holds its sleep assertions until you press Control-C or close the window. It changes no system setting, so there is nothing to undo.
| Flag | What it does | Glowmoth equivalent |
|---|---|---|
-d | Prevents the display from sleeping | Keep the display on (on by default for your session) |
-i | Prevents idle system sleep; the display may still sleep | A session with Keep the display on turned off |
-m | Prevents the disk from idle sleeping | None |
-s | Prevents system sleep; only works on AC power | None |
-u | Declares the user active (wakes the display if it is off) | None |
-t <seconds> | Stops after a number of seconds | glowmoth for 2h |
-w <pid> | Stays awake until that process exits | glowmoth wait <pid> |
| a command | Stays awake while the command runs | glowmoth run -- <command> |
Why the combination looks redundant
The flags overlap, and a few have catches:
-dalready implies a lot. Holding the display on also keeps the system awake, so-dalone covers many "just keep it on" cases.-sonly works on AC power. On a MacBook running on battery it has no effect, so-dimsubehaves like-dimthere.-uis short-lived by default. Without-t, the user-active assertion lasts only 5 seconds. In-dimsu, the other flags do the long holding.-umostly matters when the display is already off and you want it woken.- Plain
caffeinateis just-i. With no flags it blocks idle sleep, but the display can still go dark.
Which flags you actually need
Pick by the job:
| Job | Command |
|---|---|
| Long download, build or agent run; screen can go dark | caffeinate -i |
| Screen must stay on (presentation, dashboard) | caffeinate -d |
| One command, then let the Mac sleep again | caffeinate -i make |
| A fixed time | caffeinate -i -t 3600 (seconds) |
| Until a running process finishes | caffeinate -i -w 1234 |
For example, this holds the Mac awake while make runs and releases it when make exits:
caffeinate -i makeAdd -m only if you have a spinning external disk that must not idle, and -u only if you need the display woken. -s matters mainly on a desktop or a plugged-in laptop where you want the stronger system-sleep hold.
Check that it is working
In a second Terminal window, run:
pmset -g assertionsThis lists every sleep-blocking assertion and the process holding it. You should see caffeinate with the assertions you asked for. It also shows whether something else is holding the Mac awake.
Doing the same with Glowmoth
Glowmoth is a menu bar app that covers -d, -i, -t, -w and the command wrapper. It does not cover -s, -m or -u. The point of it is that you can see and stop the hold without keeping a Terminal window open.
Glowmoth holds one power assertion at a time, in one of two kinds: system only (like -i) or display on (like -d). Each one is named, for example "Glowmoth: Session for 1 hour", so pmset -g assertions explains it.
To use it from Terminal, install the command-line tool under Settings ▸ Advanced ▸ Command Line ▸ Command-line tool ▸ Install. Then:
glowmoth for 2h
glowmoth on --no-display
glowmoth wait 1234
glowmoth run -- makeglowmoth for 2hkeeps the Mac awake for two hours, likecaffeinate -t 7200. It follows your Keep the display on setting; add--no-displayto let the display sleep.glowmoth on --no-displaystarts a session with your default duration and lets the display sleep, like-i. The default is Indefinitely until you change it in Settings ▸ Sessions.glowmoth wait 1234stays awake until process 1234 exits, like-w.glowmoth run -- makestays awake whilemakeruns and returns its exit code. If the app isn't running, it holds its own assertion, so it still works.
Glowmoth needs a license or an active trial to hold the Mac awake. Without one, the app holds nothing.
What has no Glowmoth equivalent
-s: Glowmoth never uses the "prevent system sleep" assertion. For a MacBook with the lid closed it has a separate closed-lid mode, which needs a helper approved in Login Items. It is not a substitute for-s.-m: there is no disk-idle assertion. Keep drives from sleeping (Settings ▸ Advanced ▸ Drives) writes a small hidden file to the external or network drives you choose every few minutes. That is a different mechanism.-u: Glowmoth cannot declare the user active or wake the display.
If you need those three, keep using caffeinate. For the other flags, the built-in tool is free and perfectly good; an app only adds a visible on/off state, rules and a list of what else is holding the Mac awake.
Checklist before you try again
- The Terminal window running
caffeinateis still open (or you used a menu bar app). - You added
-dif the screen must stay on. - You are on AC power if you rely on
-s. pmset -g assertionsshows the assertion you expect.- You are not testing with Apple menu ▸ Sleep or a closed lid.
If it doesn't work
- The display still sleeps. You used
-ior plaincaffeinate. Add-d, or in Glowmoth turn on Keep the display on. - The Mac sleeps when you close the lid. Neither a normal
caffeinaterun nor a normal Glowmoth session stops lid-close sleep. Glowmoth's closed-lid mode exists for laptops, with the limits on its page. - It stopped when you closed Terminal.
caffeinateends with its window. Keep the window open, or use a menu bar app. -sdoes nothing. You are probably on battery.- Something else forces sleep. Check
pmset -g assertionsfor a scheduled sleep or an auto log-out. Glowmoth's panel lists other apps holding the Mac awake under Show More (Also Keeping This Mac Awake), includingcaffeinate, and flags scheduled sleep and auto log-out.
If none of this explains it, contact Apple Support, or the app's developer if a third-party app is involved. Include your macOS version, whether it is a laptop or desktop, the exact command, and the output of pmset -g assertions.
My Mac sleeps even though I ran "caffeinate -dimsu".
macOS version: (your version). Mac model: (your model).
Power: AC / battery. Lid open / closed.
Output of "pmset -g assertions" is attached.
What I already tried: -d alone, -i alone, keeping Terminal open.Common questions
Is -dimsu better than -di?
Not usually. -d and -i cover the display and idle system sleep. Add -m for idle disks, -s on AC power, -u to wake the display, only if you need them.
Does caffeinate survive a restart or logout?
No. It runs as a normal process and ends when you stop it, close its window, or the session ends. Nothing persists.
Can I run caffeinate for a set time?
Yes: caffeinate -i -t 3600 holds for 3,600 seconds. Glowmoth's equivalent is glowmoth for 1h.
Why does the Mac still sleep with the lid closed?
These assertions block idle sleep, not lid-close sleep. A MacBook normally sleeps on lid close unless it has power and an external display, or a dedicated closed-lid mode is on.