A long job — a video encode, a large download, a backup over the network — is exactly when macOS decides to sleep. Preventing that is a one-line command or a menu bar toggle, and the two solve slightly different problems.
The Built-In Command
caffeinate ships with macOS and prevents sleep for as long as it runs:
caffeinate -i make build
The flags matter:
-iprevents idle sleep — the display can still turn off-dprevents display sleep as well-mprevents disk sleep-sprevents system sleep even on AC power, and only takes effect while charging-t 3600sets a timeout in seconds
Running caffeinate -i with no command keeps the Mac awake until you stop it
with Control-C. Running it in front of a command keeps the Mac awake only for
that command’s lifetime, which is the version worth remembering — the assertion
is released automatically when the job ends.
To confirm what is currently preventing sleep:
pmset -g assertions
That lists every assertion with the process holding it, which is how you find out that something else is already keeping the machine awake.
The Menu Bar Toggle
Amphetamine puts the same capability behind a menu bar switch: turn it on, choose a duration or a trigger, and it holds the assertion until the condition is met. Useful triggers include a specific app running, a download being active, or the machine being on power.
The reason to prefer it over caffeinate is convenience and the options around
lid close. The reason to prefer caffeinate is that it needs no installation
and works over SSH on a machine you are not sitting in front of.
The Lid Problem
Closing the lid sleeps the Mac regardless of what is holding an assertion — unless one of two conditions is met: the machine is connected to power and an external display, or a tool explicitly overrides lid-close sleep.
If the task must survive a closed lid, the reliable setup is a clamshell configuration with power and a display attached. Overriding lid sleep on battery is possible with third-party tools and is the configuration most likely to cook a laptop in a bag.
What Actually Needs This
Not everything does. macOS already defers sleep for active network transfers and for many media operations. The cases where an explicit assertion helps:
- Compiling or rendering with long silent phases
- A backup or sync over a slow connection
- A remote session you are driving from another machine
- Anything where the tool reports no progress for minutes at a time
The Counterpart Problem
The opposite failure — a Mac that never sleeps — drains a battery and keeps the
machine warm. If you have used an assertion tool, check that it is not still
holding one. pmset -g assertions shows every active claim, including ones left
behind by a script that exited badly.
For a machine that is awake but sluggish instead, the more useful check is thermal — our guide to monitoring temperature, fans and battery covers what the numbers should look like.
Frequently Asked Questions
Why does my Mac still sleep when I close the lid?
Sleep on lid close is a hardware-level action, and preventing it requires either an external display and power, or a tool that specifically overrides lid-close sleep. Blocking idle sleep alone does not cover it.
Does keeping a Mac awake damage it?
No. It runs warmer and uses more power, and a laptop on battery will drain faster. There is no wear mechanism specific to staying awake, but sustained heat does accelerate battery ageing over time.



