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.
More on Processes, services and systemd
Your team has a Python API that someone starts with `nohup python app.py &`. Make it a proper service running as a non-root user.BeginnerThe service you created must bind to port 443, but it runs as a non-root user. How?BeginnerYou need to change one setting (memory limit) in a vendor-supplied unit file without editing it. How?BeginnerA service depends on a database on the same host and fails at boot because the DB isn't ready. How do you fix the ordering?IntermediateA service keeps crashing and systemd stops restarting it after a few attempts. How do you tune this?IntermediateA long-running app must reload its config without dropping connections. How do you wire this into systemd?Intermediate