LinuxCommandLibrary

caffeinate

Prevent system from going idle/sleep

TLDR

Prevent desktop from sleeping (use to exit)

$ caffeinate
copy

SYNOPSIS

caffeinate [-dimtu] [-t timeout] [command …]

PARAMETERS

-d
    Prevent display idle sleep or dimming (default behavior)

-i
    Prevent idle system sleep

-m
    Prevent idle system disk sleep

-t timeout
    Exit after specified seconds

-u
    Prevent user idle assertions

DESCRIPTION

Caffeinate is a utility primarily available on macOS that temporarily inhibits the system's power-saving features, such as idle sleep, display sleep, and disk sleep. It is useful for running long tasks like downloads, compilations, or video encoding without the machine suspending itself.

By default, caffeinate prevents the display from sleeping and runs either an interactive shell or a specified command until interrupted or timed out. It creates prevention assertions managed by the system's power management daemon. Multiple options can be combined to fine-tune behavior, like preventing only disk sleep during heavy I/O operations.

Important for Linux users: This is not a native Linux command. Linux systems use alternatives like systemd-inhibit for suspending inhibition, xset dpms for display control, or tools like caffeine (GUI). Ports or scripts mimicking caffeinate exist on GitHub but are unofficial.

CAVEATS

Not native to Linux; macOS-only. On Linux, may require third-party scripts or equivalents like systemd-inhibit --what=sleep:display 'command'. Behavior varies by desktop environment (GNOME, KDE). No universal standard.

EXAMPLES

caffeinate -t 3600 — Run shell for 1 hour.
caffeinate -dims make — Compile with full inhibition.
Linux equiv: systemd-inhibit --what=idle:sleep:display --why="Build" make

HISTORY

Introduced in macOS 10.8 Mountain Lion (2012) as part of Apple's command-line tools for power management. Remains in current macOS versions with minor updates for new assertions.

SEE ALSO

systemd-inhibit(1), xset(1), pm-suspend(8), rtcwake(8)

Copied to clipboard