---
title: "Why does systemctl poweroff wait 30 seconds before anything stops? | Proofline"
description: "A plain systemctl poweroff goes through systemd-logind, which holds the shutdown while a process has a delay inhibitor lock, up to InhibitDelayMaxSec."
url: https://proofline.sh/learn/systemctl-poweroff-logind-inhibit-delay/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# Why does systemctl poweroff wait 30 seconds before anything stops?

A plain systemctl poweroff goes through systemd-logind, which holds the shutdown while a process has a delay inhibitor lock, up to InhibitDelayMaxSec. The default is 5 seconds, and Debian's and Ubuntu's unattended-upgrades package raises it to 30 and holds such a lock. If your VMs take about 30 seconds longer to stop than their services need, list the inhibitors and read that setting. --no-block does not skip the wait, and neither does --check-inhibitors=no; --force does, at the cost of a clean stop.

Capacity overruns The Proofline team December 2, 2026 6 min read

## How a power-off request reaches logind

`systemctl poweroff` does not start `poweroff.target` directly. Without `--force` it asks logind to power off, so that logind can apply inhibitor locks first. A process takes a lock through logind's API, or with `systemd-inhibit`, in one of two modes, described in [systemd's inhibitor locks](https://systemd.io/INHIBITOR_LOCKS/):

-   A _block_ lock refuses the shutdown request outright, until the lock is released.
-   A _delay_ lock lets the request through but holds the start of shutdown. logind sends the holder a `PrepareForShutdown` signal and waits for it to release the lock, for at most `InhibitDelayMaxSec`. [logind.conf(5)](https://www.freedesktop.org/software/systemd/man/latest/logind.conf.html) sets the default to 5 seconds.

A holder that releases its lock promptly costs almost nothing. A holder that never responds, or that waits for work it has no reason to wait for, costs the whole delay on every shutdown, and nothing in the shutdown log names it: the units simply start stopping late.

unattended-upgrades is a common holder. Its shutdown helper takes a delay lock so that an upgrade in progress can finish before the machine goes down, and the package installs a logind drop-in at `/usr/lib/systemd/logind.conf.d/unattended-upgrades-logind-maxdelay.conf` that sets `InhibitDelayMaxSec=30`. On a long-lived server that protects a running upgrade. On a disposable VM that is deleted after one job, it adds 30 seconds to each delete.

## The lab

The lab runs systemd as PID 1 in a privileged container. Use a throwaway Docker host with `bc` installed for the timing script. The image is Debian with systemd and D-Bus.

```
FROM debian:trixie
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends systemd systemd-sysv dbus libpam-systemd >/dev/null
CMD ["/sbin/init"]
```

The script boots a container from it, sets `InhibitDelayMaxSec=30` like the unattended-upgrades drop-in, starts a process that takes a delay lock and never releases it, then powers off and times how long the container takes to stop. `NOHOLD=1` skips the lock and `NODROP=1` skips the drop-in.

```
#!/bin/bash
# usage: run.sh NAME POWEROFF-ARGS...
name=$1; shift
docker run -d --name $name --privileged --cgroupns=private --tmpfs /run --tmpfs /run/lock lab-logind-inhibit >/dev/null
until docker exec $name systemctl is-active -q systemd-logind 2>/dev/null; do :; done
docker exec -e NODROP=$NODROP -e NOHOLD=$NOHOLD $name sh -c '
mkdir -p /etc/systemd/logind.conf.d
[ "$NODROP" = 1 ] || printf "[Login]\nInhibitDelayMaxSec=30\n" > /etc/systemd/logind.conf.d/lab.conf
systemctl restart systemd-logind
[ "$NOHOLD" = 1 ] || systemd-run --unit=holder systemd-inhibit --what=shutdown --mode=delay --who=holder --why="finish before shutdown" sleep infinity >/dev/null
sleep 1; systemd-inhibit --list --no-pager | head -3'
start=$(date +%s.%N)
docker exec $name systemctl poweroff "$@" || true
docker wait $name >/dev/null
end=$(date +%s.%N)
printf "systemctl poweroff %s: container stopped after %.1f s\n" "$*" $(echo "$end - $start" | bc)
docker rm $name >/dev/null
```

```
docker build -q -t lab-logind-inhibit .
NOHOLD=1 ./run.sh lab-a
./run.sh lab-b
./run.sh lab-c --no-block
./run.sh lab-d --check-inhibitors=no
./run.sh lab-e --force
NODROP=1 ./run.sh lab-f
```

On systemd 257, the inhibitor list showed the lock:

```
WHO    UID USER PID COMM            WHAT     WHY                    MODE
holder 0   root 137 systemd-inhibit shutdown finish before shutdown delay
```

and the six runs printed:

```
systemctl poweroff : container stopped after 0.7 s                  (no lock)
systemctl poweroff : container stopped after 31.4 s
systemctl poweroff --no-block: container stopped after 31.6 s
systemctl poweroff --check-inhibitors=no: container stopped after 30.9 s
systemctl poweroff --force: container stopped after 0.4 s
systemctl poweroff : container stopped after 5.9 s                  (logind default)
```

The labels in parentheses are added; the rest is the script's output. One delay lock turned a stop of under a second into 31 seconds. Without the drop-in, the same lock cost the default 5 seconds.

Two results contradict a common guess. `--no-block` only makes `systemctl` return before the operation completes; the [systemctl(1)](https://man7.org/linux/man-pages/man1/systemctl.1.html) page already describes `poweroff` as asynchronous, and the shutdown still waits. `--check-inhibitors=no` disables the check that would refuse the request on a _block_ lock, but logind still honours the _delay_ lock.

## Find the delay on a real machine

Three readings tell you whether this is your problem, before you change anything:

```
systemd-inhibit --list
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
  org.freedesktop.login1.Manager InhibitDelayMaxUSec
systemd-analyze cat-config systemd/logind.conf
```

In the lab container the property read `t 30000000`, 30 seconds in microseconds, and `cat-config` showed the drop-in that set it. On the machine, the journal of the previous boot (`journalctl -b -1 -o short-precise`) shows the gap: the line that requested the power-off, then nothing until units start stopping. A gap equal to `InhibitDelayMaxSec` points at a delay lock whose holder did not let go.

## Choose the fix

Which fix fits depends on what the machine still has to do when it stops.

-   **The machine is disposable and its work is saved.** Use `systemctl poweroff --force`. It skips logind and the orderly stop of each unit; per systemctl(1), all processes are killed and file systems are unmounted or remounted read-only. Anything a process had not written yet is lost, so do this only after the job has reported and uploaded what matters. [An empty log after a kill](/learn/empty-log-after-kill/) shows what a forced end does to buffered output.
-   **The machine runs services that need a clean stop.** Keep the orderly shutdown and shorten or remove the delay: set a lower `InhibitDelayMaxSec` in a later drop-in under `/etc/systemd/logind.conf.d/`, or remove the package that holds the lock from images that never upgrade themselves.
-   **The holder is your own process.** Release the lock when `PrepareForShutdown` arrives, after doing only the work that has to finish before shutdown.

Shutdown time also matters on platforms that stop instances for you; [sessions left behind after a rollout](/learn/cloud-run-shutdown-cloud-sql-connections/) covers the other side, a process that does not finish its cleanup within the grace it is given.

## The production case

In the production case behind this guide, short-lived VMs ran one sandboxed job each and were deleted afterwards. A job slot took 97 seconds, 43 of them the delete. Over one day, 2,180 deletes of still-running guests took 42.1 seconds at the median and 50.7 at p90; the 11 deletes of guests already powered off took 4.8 and 11.4. The serial console of one guest showed the agent exiting and its unit calling `systemctl poweroff --no-block`, then no unit stopping for 30.2 seconds. The image kept unattended-upgrades and its 30-second drop-in. In a 20-minute capture, 31 of 32 VMs spent more than 29 seconds stopping. The fix powers the guest off with `--force`, since the job has already uploaded its results and the disk is deleted with the VM.

## Where this came from

Proofline found this in the VMs that run its sandboxed jobs and shipped the forced power-off in its production release of 28 November 2026. The durations in [The production case](#case) are those VMs' audit log and serial console readings before the change. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. [Start a free GitHub review](https://proofline.sh/orgs/plan?offer=free150) · [Eligibility and fair-use terms](/free-code-review/)

## Questions

### What is InhibitDelayMaxSec?

A logind setting: the longest time a shutdown or sleep request waits for processes holding delay inhibitor locks before it goes ahead anyway. The default is 5 seconds; unattended-upgrades ships a drop-in that sets 30.

### Does systemctl poweroff --no-block skip inhibitors?

No. It makes `systemctl` return without waiting for the operation, and the power-off itself still waits for delay locks. In the lab it stopped after 31.6 seconds, the same as without the flag.

### Is systemctl poweroff --force dangerous?

It kills processes without stopping their units in order, so services lose anything they had not written. For a disposable VM, confirm the required output has already reached durable storage and that the workload needs no shutdown hooks. On a database server, use an orderly shutdown.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [An empty log does not mean the process did nothing](/learn/empty-log-after-kill/)
    
    Broken dependencies The Proofline team November 24, 2026 3 min read
    
-   ### [Sessions left in Cloud SQL after a Cloud Run rollout: shutdown or leak?](/learn/cloud-run-shutdown-cloud-sql-connections/)
    
    Broken dependencies The Proofline team November 23, 2026 6 min read
