On a systemd machine (e.g. Debian), whenever I issue a reboot, among the very first things that get killed is sshd
. This wasn't the case in the not-so-great-but-also-not-too-bad sysvinit days, where I could still watch and sometimes fix issues going wrong during a reboot via SSH.
I'd be fine with sshd to not get sent a TERM
signal at all or ideally as one of the very last processes, even after network has been shut down. Is there a way to achieve this with systemd?
I'd also be interested in a way to make sshd
get started as one of the first services, but that's less of a priority.
What are you going to observe and accomplish in 2 seconds? That is the time I observe a shutdown taking in its entirety: from terminating services, ifdown interfaces, unmount file systems, and TERM all processes. I tested with Debian Stretch on Google Cloud, built on 20190326.
Stopping services takes out their slices, and it is done in parallel. Their process tree including your sessions are rapidly terminated. I'm not aware of a configuration that will output anything useful before your session is gone.
You can have events logged via journald with
Storage=persistent
, or possibly sent to a remote system with systemd-journal-remote. Logs from the previous boot can be retrieved withjournalctl -b -1
. Either get back on the rebooted system with ssh or console, or look at remote logs.