caffeinate command builder
macOS can keep itself awake from the Terminal. Nobody remembers the flags. Pick what you're doing and copy the command.
What are you keeping awake for?
Which command?
For how long?
The screen?
caffeinate -dimsu
What this command can't do
caffeinate is a blunt instrument. It holds a power assertion and nothing else. It has no idea what your Mac is doing, and it will not stop on its own.
- It dies with the terminal. Close the tab or window and your Mac starts sleeping again mid-job. The window has to stay open the whole time.
- It cannot survive a closed lid. Shut the lid and macOS force-sleeps regardless. No caffeinate flag overrides this.
- It will flatten your battery. There is no low-power cutoff. Left running unplugged, it holds the Mac awake until the battery is empty and the machine dies.
- It ignores heat. No thermal awareness at all. It keeps the Mac awake whether it is cool or cooking.
- You have to remember it. Every session, before the job starts, typed correctly. Miss it once on the run that mattered and you have lost the night's work.
- There is no indicator. Nothing tells you it is on, so people forget and leave their Mac awake for days.
A warning about the other command people use. If you search this problem you will find sudo pmset -a disablesleep 1. Do not use it casually. Unlike caffeinate, that changes a permanent system setting. It stays on after you close the terminal, after you log out, and after you reboot, until you explicitly turn it off. That is how people end up with a laptop running hot in a bag.
One click, and it knows when to stop
Awake does everything the command does, from a menu bar switch, plus the things it structurally cannot: it keeps running with the lid closed, and it looks after your machine while you are away.
| caffeinate | Awake | |
|---|---|---|
| Keeps the Mac awake | Yes | Yes |
| Setup each time | Type the command | One click |
| Survives closing the terminal | No | Yes |
| Works with the lid closed | No | Yes |
| Stops before your battery dies | No | Yes, at 20% |
| Stops if the Mac gets hot | No | Yes |
| Shows you it's running | No | Menu bar icon |
| Timed sessions | Flag only | 30m / 1h / 5h |
Free 3-day trial, no card. Notarized by Apple. $14.99 once, not a subscription.
Questions
How do I stop it?
Press Control-C in that terminal, or close the tab. If you backgrounded it, run pkill caffeinate. Sleep goes back to normal immediately.
How do I check it's working?
Run pmset -g assertions. You'll see the active assertions and which process owns them.
Does it work with the lid closed?
No. Closing the lid triggers a clamshell sleep that a normal assertion can't override. That needs a privileged helper, which is what Awake ships.
Will it drain my battery?
It can. caffeinate has no low-battery cutoff, so use a time limit above if you're unplugged.
Why does my Mac sleep during a Claude Code or Codex run?
macOS measures user input, not CPU load. An agent thinking with no keystrokes looks idle. More on that here.
More detail: the complete caffeinate guide · keeping your Mac awake for AI agents