O comentário do Bigon está correto. Eu estava procurando em /var/log/syslog
, mas isso é escrito por rsyslog.service
, que systemd pára muito cedo no processo de desligamento (como indicado por "Stopped System Logging Service" abaixo).
Depois que eu habilitei o log journaling persistente ( Storage=persistent
in /etc/systemd/journald.conf
e systemctl restart systemd-journald
), journalctl -b-1 -u shutdowntest.service
mostra que meu serviço realmente tem tempo suficiente para desligar depois que o sistema é reboot
ed, shutdown
, ou após a tecla Power ser pressionada (ACPI G2 Soft Off).
journalctl -b-1 -u shutdowntest.service -u rsyslog.service -u systemd-logind
-- Logs begin at Mon 2018-03-26 18:39:12 UTC, end at Mon 2018-03-26 20:22:34 UTC. --
…
Mar 26 18:46:46 myhost systemd-logind[1202]: Power key pressed.
Mar 26 18:46:46 myhost systemd-logind[1202]: Powering Off...
Mar 26 18:46:46 myhost systemd-logind[1202]: System is powering down.
Mar 26 18:46:46 myhost shutdowntest.sh[1237]: Terminated
Mar 26 18:46:46 myhost shutdowntest.sh[1237]: shutdowntest received signal SIGTERM
Mar 26 18:46:46 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 10 more sleeps
Mar 26 18:46:46 myhost systemd[1]: Stopping shutdowntest.service...
Mar 26 18:46:46 myhost systemd[1]: Stopping Login Service...
Mar 26 18:46:46 myhost systemd[1]: Stopped Login Service.
Mar 26 18:46:46 myhost systemd[1]: Stopping System Logging Service...
Mar 26 18:46:47 myhost systemd[1]: Stopped System Logging Service.
Mar 26 18:46:47 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 9 more sleeps
Mar 26 18:46:48 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 8 more sleeps
Mar 26 18:46:49 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 7 more sleeps
Mar 26 18:46:50 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 6 more sleeps
Mar 26 18:46:51 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 5 more sleeps
Mar 26 18:46:52 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 4 more sleeps
Mar 26 18:46:53 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 3 more sleeps
Mar 26 18:46:54 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 2 more sleeps
Mar 26 18:46:55 myhost shutdowntest.sh[1237]: shutdowntest Shutting down: 1 more sleeps
Mar 26 18:46:56 myhost shutdowntest.sh[1237]: shutdowntest Finished shutting down; quitting
Mar 26 18:46:56 myhost systemd[1]: Stopped shutdowntest.service.