{
  "id": 12549623,
  "title": "Stop Losing Work Mid-Job: Practical systemd-inhibit on Linux",
  "url": "https://urgent.news/2026/10/07/stop-losing-work-mid-job-practical-systemd-inhibit-on-linux",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-07T05:02:50.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lyraalishaikh/stop-losing-work-mid-job-practical-systemd-inhibit-on-linux-32c2"
  },
  "original_language": "en",
  "account": "When performing long-running tasks on Linux, such as rsync or backups, it's common for the system to unexpectedly suspend, shut down, or enter idle mode, interrupting the job. This issue arises when no inhibitor locks are in place to prevent these types of interruptions. Inhibitor locks are a feature of systemd-logind that allow applications and operators to temporarily block or delay sleep, shutdown, idle action, and even the handling of power/lid keys. The command-line front end for managing these locks is systemd-inhibit. The protocol for these locks is detailed in the upstream Inhibitor Locks page and the org.freedesktop.login1(5) documentation.\n\nThis guide is aimed at operators and provides step-by-step instructions on listing active locks, wrapping real jobs to prevent interruptions, putting inhibitors on oneshot services, tuning logind.conf delay budgets, and knowing when not to take a blocking lock. It is important to understand that inhibitor locks do not replace backups, fencing, or package-manager locks; they simply prevent logind-mediated interruptions and allow the job to complete uninterrupted. The mental model for using inhibitor locks involves a single D-Bus call: Inhibit(what, who, why, mode) → file descriptor. After executing the command, the lock is automatically removed when the file descriptor is closed, ensuring no stale locks are left in the database.",
  "summary": "You start a multi-hour rsync , walk away, and the laptop suspends halfway through. Or someone hits reboot while apt full-upgrade is unpacking. Or a headless box with IdleAction=suspend parks itself mid-backup because every session looked idle. Those are not application bugs. They are missing inhibitor locks . systemd-logind owns a small, deliberate API for this: applications (and operators) can…",
  "key_points": [
    "Systemd-inhibit prevents interruptions during long-running Linux tasks.",
    "Inhibitor locks block sleep, shutdown, idle actions, and power/lid key handling.",
    "Systemd-inhibit command creates a file descriptor to automatically remove the lock."
  ],
  "editors_take": "Using systemd-inhibit to manage inhibitor locks helps prevent interruptions to long-running Linux tasks, allowing operators to ensure jobs complete uninterrupted, without replacing other essential precautions like backups.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}