Interview Prep/Linux/Processes, services and systemd

A Java service takes 3 minutes to shut down and systemd kills it after 90 seconds, corrupting state. Fix it.

IntermediateScenarioProcesses, services and systemd
Answer

Situation read → Default stop timeout is too short.

What I'd do →

[Service]
TimeoutStopSec=300
KillSignal=SIGTERM
KillMode=mixed

Then investigate why shutdown takes 3 minutes (draining connections, flushing caches).

Why → systemd sends KillSignal, waits TimeoutStopSec, then sends SIGKILL. KillMode=mixed sends SIGTERM only to the main process and SIGKILL to leftovers at the end.

Interview tip → Mention that DefaultTimeoutStopSec is set globally in /etc/systemd/system.conf.

All Linux questions Roadmap: Linux

More on Processes, services and systemd