Why Your systemd Service Gets SIGKILLed at 90 Seconds
Bottom line: If your service ignores SIGTERM, systemd will SIGKILL it 90 seconds into a stop — because DefaultTimeoutStopSec=90s sets the deadline, TimeoutStopSec inherits it, and KillMode=control-group sends the final SIGKILL to every process left in the cgroup.
The 90-second figure is not a hardcoded constant in systemd’s source. It is the compiled-in default for DefaultTimeoutStopSec, which the manager reads from system.conf and applies to any service that does not override TimeoutStopSec. The service gets SIGTERM first, then a grace period, then SIGKILL. If you have ever watched a unit sit in deactivating for exactly a minute and a half and then vanish, that is this mechanism, not a bug and not the OOM killer.
Where the 90 seconds actually comes from
systemd’s manager configuration lives in system.conf and its drop-ins. The relevant knob is DefaultTimeoutStopSec, and the shipped file on most distributions has it commented out with the default shown:
1 | $ grep -n 'DefaultTimeoutStopSec\|DefaultTimeoutStartSec' /etc/systemd/system.conf |
Because the line is commented, the value comes from compilation. You can confirm the effective value on a running system without reading the source:
1 | $ systemctl show --property=DefaultTimeoutStopSec |
A service unit that does not set TimeoutStopSec inherits this. That inheritance is the whole story. The per-unit property is what the stop job actually enforces:
1 | $ systemctl show --property=TimeoutStopUSec --property=KillMode --property=SendSIGKILL myservice.service |
Three properties, one deadline. TimeoutStopUSec is the deadline, KillMode decides who gets signalled, and SendSIGKILL decides whether the deadline ends in a kill or in systemd simply giving up and logging a warning.
The stop sequence, step by step
When you run systemctl stop myservice, the manager does the following, in order:
- Marks the unit
deactivating. - Runs
ExecStop=if defined. This command has its own timeout budget, and it counts against the same stop deadline in most configurations. - Sends the signal configured by
KillSignal=(default SIGTERM) to the processes selected byKillMode=. - Waits up to
TimeoutStopSecfor those processes to exit. - If any remain and
SendSIGKILL=yes, sends SIGKILL to the remaining processes according toKillMode=. - Marks the unit
inactiveorfaileddepending on the exit statuses.
The critical detail is step 3 versus step 5. With KillMode=control-group — the default — SIGTERM goes to every process in the unit’s cgroup, not just the main PID. Then SIGKILL, at the deadline, also goes to every process in the cgroup. With KillMode=mixed, SIGTERM goes only to the main process, but the SIGKILL at the deadline still hits the whole cgroup. With KillMode=process, only the main process is ever signalled, and children can survive the stop entirely — which is why the man page calls it “not recommended”.
| Setting | SIGTERM target | SIGKILL target (at deadline) | Typical use |
|---|---|---|---|
control-group (default) |
All processes in cgroup | All processes in cgroup | Almost everything |
mixed |
Main process only | All processes in cgroup | Services that fork workers and clean up their own children |
process |
Main process only | Main process only | Wrappers that must not kill their children |
none |
Nothing | Nothing | Units that manage their own lifecycle entirely |
The mixed row is the one people reach for when a service spawns worker processes that should be allowed to drain. It changes who receives SIGTERM, not who receives SIGKILL. That distinction trips people up constantly.
Proving it with the journal and the cgroup
The journal records the timeout explicitly. When a unit is killed at the deadline you get a line like this, and it names the exact property:
1 | $ journalctl -u myservice.service -o short-precise --since '10 min ago' |
Read the timestamps. SIGTERM at 09:41:02, SIGKILL at 09:42:32. That is 90 seconds to the millisecond. The message State 'stop-sigterm' timed out is systemd telling you which state machine phase expired, and Failed with result 'timeout' is the unit result you will see in systemctl status.
The cgroup view corroborates it. While the unit is stuck in deactivating, list its cgroup and you will see the processes that are ignoring SIGTERM:
1 | $ systemctl status myservice.service --no-pager |
Note that the main PID is already dead from SIGTERM but two workers remain. This is the classic KillMode=mixed scenario: the main process exited cleanly, the workers did not, and the stop job is now counting down to SIGKILL for the whole cgroup. If you want to see the same thing from the cgroup filesystem directly:
1 | $ systemctl show --property=ControlGroup myservice.service |
Those PIDs are what SIGKILL will hit at the deadline.
Changing the deadline correctly
Do not edit /etc/systemd/system.conf unless you intend to change the default for every unit on the host. Use a drop-in on the service instead:
1 | $ systemctl edit myservice.service |
That opens an override file at /etc/systemd/system/myservice.service.d/override.conf. Put the stop behaviour there:
1 | [Service] |
TimeoutStopUSec=infinity is worth understanding: it disables the stop timeout entirely for that unit, which means systemd will wait forever and your shutdown will hang. Use it only for units you genuinely trust to exit, and never on a unit that runs at shutdown. The safer pattern is a finite TimeoutStopSec sized to your actual drain time, plus a service that handles SIGTERM properly.
If you want to change the host-wide default, the drop-in goes in /etc/systemd/system.conf.d/, and the filename should sort after vendor drop-ins:
1 | # /etc/systemd/system.conf.d/60-stop-timeout.conf |
Reload with systemctl daemon-reload for unit changes; manager configuration changes need systemctl daemon-reexec or a reboot to take effect. Verify with systemctl show --property=DefaultTimeoutStopSec afterwards.
Pitfalls and how to diagnose them
The service traps SIGTERM but never exits. A handler that sets a flag and waits for a queue to drain will hang forever if the queue never drains. Diagnose with systemctl status during the stop window: if the main PID is still alive at 60 seconds, the handler is the problem. Fix the handler, not the timeout.
ExecStop= consumes the budget. The stop command runs before SIGTERM and counts against TimeoutStopSec in the common case. A slow ExecStop= script can leave almost no grace period for the actual process. Check the journal for the ExecStop invocation timestamp versus the SIGTERM timestamp.
KillMode=process leaves orphans. Children survive the stop, keep the cgroup populated, and the unit may never reach inactive cleanly. Look for processes in the cgroup after systemctl stop returns: cat /sys/fs/cgroup/system.slice/myservice.service/cgroup.procs should be empty.
Type mismatch hides the real main process. With Type=simple, the main PID is the forked process, and a wrapper script that execs the real binary is fine — but a wrapper that forks and exits is not. Type=forking with a wrong PIDFile= means systemd tracks the wrong process and SIGTERM goes to the wrong place. Verify with systemctl show --property=MainPID and compare against ps.
Shutdown ordering makes it worse. At shutdown, shutdown.target conflicts with normal services, and every unit gets its stop job. If several units each burn 90 seconds, shutdown takes minutes. systemd-analyze critical-chain and journalctl -b -1 for the previous boot show where the time went.
Drop-in precedence surprises. A vendor drop-in under /usr/lib/systemd/system/*.d/ with a low number can be overridden by your /etc drop-in only if yours sorts later. Name local drop-ins with a 60- or higher prefix.
FAQ
Why exactly 90 seconds and not 60 or 120?
Because the compiled-in default for DefaultTimeoutStopSec is 90 seconds, and a unit without TimeoutStopSec= inherits it. Confirm on your host with systemctl show --property=DefaultTimeoutStopSec; distributions can and do change it at build time.
Does TimeoutStopSec apply to ExecStop= as well?
Yes, in the typical configuration the ExecStop= command runs within the same stop job and its runtime counts against the stop deadline. A slow stop script can therefore leave little or no time for SIGTERM handling before SIGKILL.
What is the difference between KillMode=mixed and KillMode=control-group?
control-group sends SIGTERM to every process in the cgroup. mixed sends SIGTERM only to the main process. In both cases the SIGKILL at the deadline goes to the entire cgroup, which is the part people miss.
Can I disable the SIGKILL entirely?
Set SendSIGKILL=no on the unit. systemd will then log a warning at the deadline and leave the processes running, which usually means the unit never reaches inactive and shutdown hangs. It exists for units that must not be killed, not as a general workaround.
Why does systemctl status show deactivating (stop-sigterm) for so long?
That state means the stop job has sent SIGTERM and is waiting for the cgroup to empty. The parenthetical names the phase. If it persists past TimeoutStopSec, you will see State 'stop-sigterm' timed out. Killing. in the journal and the SIGKILL follows immediately.
Does changing DefaultTimeoutStopSec require a reboot?
Manager configuration is read at daemon start. systemctl daemon-reexec re-executes the manager and picks up system.conf changes without a full reboot; daemon-reload only reloads unit files, not manager configuration.







