caffeinate
create a macOS power-management assertion to keep the system awake
TLDR
SYNOPSIS
caffeinate [-disum] [-t timeout] [-w pid] [utility [arguments]]
DESCRIPTION
caffeinate creates one or more IOKit power-management assertions to suppress different kinds of sleep. It is the supported way to prevent macOS from entering display, idle, disk, or system sleep for the duration of a task.When invoked with a utility, caffeinate forks and runs the utility with the assertion(s) held until the utility exits. Without a utility, it runs until it receives a signal (e.g. Ctrl-C) or until `-t` expires. Multiple flags may be combined; each adds its own assertion.
PARAMETERS
-d
Prevent the display from sleeping.-i
Prevent the system from idle sleeping. (default when no assertion flag is given)-m
Prevent the disk from idle sleeping.-s
Prevent the system from sleeping. Only effective when plugged into AC power on a laptop.-u
Declare that the user is active. The assertion is released automatically after 5 seconds (or sooner if cancelled) — useful to bump activity without holding it indefinitely.-t timeout
Release the assertion after timeout seconds. Without this flag the assertion holds until caffeinate is terminated or the wrapped utility exits.-w pid
Hold the assertion until the process with the given PID exits.utility [arguments]
If a utility is given, caffeinate runs it and holds the assertion until it exits. `caffeinate -i make` is the idiomatic pattern.
CAVEATS
macOS only (shipped in `/usr/bin/caffeinate` since OS X 10.8 Mountain Lion). On battery, `-s` may be ignored — `-i` is the reliable choice for laptops. `-u` gives only a brief nudge; use `-d -i` for longer guarantees. Creating an assertion does not override closing the laptop lid (clamshell) — for that, use `pmset`.For Linux, the equivalent is `systemd-inhibit` or `caffeine` (GNOME applet). For X11, `xset s off -dpms` controls screensaver and DPMS.
HISTORY
caffeinate was introduced in Mac OS X 10.8 (Mountain Lion, 2012) by Apple as the supported CLI replacement for ad-hoc scripts that poked mouse events to keep the Mac awake. It wraps the IOKit `IOPMAssertion` API.
SEE ALSO
caffeine(1), xset(1), systemd-inhibit(1)
