[systemd-devel] Need help: Program not run when rebooting
Ulrich Windl
Ulrich.Windl at rz.uni-regensburg.de
Thu Mar 11 14:53:55 UTC 2021
Hi!
I tried to write a simple test unit that logs a message when the system is
going down (for reboot or halt), but it does not work:
---
[Unit]
Description=Test Stop log entries
Documentation=man:logger(1)
DefaultDependencies=no
After=local-fs.target
Before=reboot.target halt.target shutdown.target poweroff.target kexec.target
Wants=local-fs.target
#ConditionPathExists=/usr/bin/logger
[Service]
Type=oneshot
TimeoutSec=5
RemainAfterExit=yes
ExecStop=/usr/bin/logger -p user.notice -t LCD Stopping...
[Install]
WantedBy=reboot.target halt.target shutdown.target poweroff.target
kexec.target
#WantedBy=multi-user.target
---
After a reboot I see:
---
jeos1:~ # systemctl status log-stop-test.service
● log-stop-test.service - Test Stop log entries
Loaded: loaded (/etc/systemd/system/log-stop-test.service; enabled; vendor
p>
Active: active (exited) since Thu 2021-03-11 15:38:42 CET; 9min ago
Docs: man:logger(1)
Tasks: 0
CGroup: /system.slice/log-stop-test.service
Mar 11 15:38:42 jeos1 systemd[1]: Started Test Stop log entries.
--
But no message was written when rebooting. That is, there is a message from
systemd, but no log:
Mar 11 15:17:33 jeos1 systemd[1]: Stopped target Local File Systems.
Mar 11 15:17:33 jeos1 systemd[1]: Started Test Stop log entries.
Mar 11 15:17:33 jeos1 systemd[1]: Unmounting /usr/local...
So I want to run my program much earlier; how to do that?
Regards,
Ulrich
More information about the systemd-devel
mailing list