How does the systemd stop command actually work?

By default, a SIGTERM is sent, followed by 90 seconds of waiting followed by a SIGKILL. Killing processes with systemd is very customizable and well-documented. I recommend reading all of man systemd.kill as well as reading about ExecStop= in man systemd.service. To respond to those signals, refer to the signal handling documentation for the language … Read more

What is the difference between systemd’s ‘oneshot’ and ‘simple’ service types?

The Type=oneshot service unit: blocks on a start operation until the first process exits, and its state will be reported as “activating”; once the first process exits, transitions from “activating” straight to “inactive”, unless RemainAfterExit=true is set (in which case it becomes “active” with no processes!); may have any number (0 or more) of ExecStart= … Read more

How systemd stop command actually works

By default, a SIGTERM is sent, followed by 90 seconds of waiting followed by a SIGKILL. Killing processes with systemd is very customizable and well-documented. I recommend reading all of man systemd.kill as well as reading about ExecStop= in man systemd.service. To respond to those signals, refer to the signal handling documentation for the language … Read more

How can I predict systemd’s shutdown order?

Maybe stating the obvious reduces the learning effect, but all I did to get the full list of reverse dependencies for shutdown-target as asked in the original post, was: systemctl list-dependencies –after shutdown.target OT: I ran in a problem where the shutdown of a kubernetes system hangs (the machine becomes irresponsive and will not shut … Read more

Wait for service to gracefully exit before machine shutdown/reboot

The comment from Bigon is correct. I was looking in /var/log/syslog, but this is written by rsyslog.service, which systemd stops pretty early in the shutdown process (as indicated by “Stopped System Logging Service” below). After I enabled persistent journald logging instead (Storage=persistent in /etc/systemd/journald.conf and systemctl restart systemd-journald), journalctl -b-1 -u shutdowntest.service shows that my … Read more