I want to log something before shutdown or poweroff.
uname -a
Linux xxx 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
systemctl get-default
graphical.target
runlevel
N 5
To edit my script.
sudo vim /etc/systemd/system/graphical.target.wants/log.service
[Unit]
Description=Run command at shutdown
Before=shutdown.target reboot.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/bin/bash /home/log.sh
To enable it.
sudo systemctl enable log.service
Failed to enable unit: File log.service: No such file or directory
How to fix it? What is the matter with the following setting?
sudo cat /etc/systemd/system/log.service
[Unit]
Description=Run command at shutdown
After=shutdown.target reboot.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStop=/bin/bash /home/log.sh
[Install]
WantedBy=graphical.target
Enable it with sudo systemctl enable log.service
without any issue.
Why no log info ,the /home/log.sh
can't execute?