先產生..
# cat /etc/systemd/system/runmyshutdown.service [Unit] Description=Run my custom task at shutdown DefaultDependencies=no Before=shutdown.target [Service] Type=oneshot ExecStart=/usr/local/bin/myshutdown.sh TimeoutStartSec=0 [Install] WantedBy=shutdown.target還有測試的 script:
# cat /usr/local/bin/myshutdown.sh #!/bin/bash /bin/touch /data/sssss然後..
# systemctl daemon-reload # systemctl enable runmyshutdown Created symlink /etc/systemd/system/shutdown.target.wants/runmyshutdown.service → /etc/systemd/system/runmyshutdown.service.原來沒有 /etc/systemd/system/shutdown.target.wants 這個目錄。
因為 WantedBy 的關係,所以新 create。
測試,reboot 後,到 /data 去看,果然有 ssss,所以是成功了。
沒有留言:
張貼留言