Block suspend while a command runs with systemd-inhibit

Wrap any long-running command so auto-suspend and idle sleep cannot interrupt it.

LinuxsleepPower & SleepsystemdLow risk
Prefix the job with systemd-inhibit --why='Downloading large file' --mode=block to hold a suspend lock until it finishes.

01Command

Command
$ systemd-inhibit --why='Downloading large file' --mode=block curl -LO https://example.com/big.iso

02What it does

Desktops suspend after an idle timeout, which happily kills a long download, rsync or benchmark. systemd-inhibit grabs the same power-management lock that media players use, for exactly as long as the wrapped command runs, and the --why string shows up in inhibit listings. Run systemd-inhibit (no arguments) to see who currently holds sleep locks.

03Risk

RiskLow risk
Requirementssystemd-based distro; no root needed. Also affects lid close handling when used with delay/block modes.
!Warning: block mode only prevents automatic suspend — closing the laptop lid can still suspend depending on logind settings (HandleLidSwitch). If the wrapped command hangs, the machine stays awake indefinitely, so prefer it for bounded jobs.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • systemd-inhibit(1) - Ubuntu manpage
    Ubuntu Manpages · community · 2026-09-17
    Evidence: Same synopsis; explains that --mode=block takes the lock for the duration of the wrapped command and --why= sets a human-readable reason.
  • systemd-inhibit(1) — Arch Manual Pages
    Arch Linux · community · 2026-09-17
    Evidence: Documents systemd-inhibit [OPTIONS...] [COMMAND] with --what=, --who=, --why= and --mode= (block/delay) options.

Last verified: 2026-09-19 · Category: System & Settings

06Related solutions