The following is for a systemd service that runs (successfully) right before I can log in and runs my script.But, the problem is, ideally, I'd like for my script to run right before the shutdown process, rather than right before I can log in (mostly because I prefer adding to my shutdown time rather than my bootup time).
So, I unsuccessfully tried a systemd service like the following.:I also tried shutdown.target and final.target, but those were unsuccessful too.
Could someone please tell me why this isn't working and/or how I can get it to work?
Any input would be greatly appreciated!
P.S.
I do systemctll disable my_service.service and then systemctl enable my_service.service, and I rebooted at least twice (and also shut down and started up again at least twice), and it's still not working.
I use journalctl -u my_service.service and observe the debugging output (via echo statements) of my_script.sh in the displayed log (at the end of it, where the latest output is) to see whether it's successful or not.
Code:
[Unit]Description=Some description.Before=multi-user.target[Service]ExecStart/usr/local/sbin/my_script.shType=oneshotRemainAfterExit=no[Install]WantedBy=multi-user.target
So, I unsuccessfully tried a systemd service like the following.:
Code:
[Unit]Description=Some description.Before=poweroff.target[Service]ExecStart/usr/local/sbin/my_script.shType=oneshotRemainAfterExit=no[Install]WantedBy=poweroff.target
Could someone please tell me why this isn't working and/or how I can get it to work?
Any input would be greatly appreciated!
P.S.
I do systemctll disable my_service.service and then systemctl enable my_service.service, and I rebooted at least twice (and also shut down and started up again at least twice), and it's still not working.
I use journalctl -u my_service.service and observe the debugging output (via echo statements) of my_script.sh in the displayed log (at the end of it, where the latest output is) to see whether it's successful or not.
Statistics: Posted by s3a — 2024-01-10 06:24 — Replies 0 — Views 847