Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 3260

System and Network configuration • It seems I can get a systemd service running right before I have to login, but not right before shutting down.

$
0
0
The following is for a systemd service that runs (successfully) right before I can log in and runs my script.

Code:

[Unit]Description=Some description.Before=multi-user.target[Service]ExecStart/usr/local/sbin/my_script.shType=oneshotRemainAfterExit=no[Install]WantedBy=multi-user.target
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.:

Code:

[Unit]Description=Some description.Before=poweroff.target[Service]ExecStart/usr/local/sbin/my_script.shType=oneshotRemainAfterExit=no[Install]WantedBy=poweroff.target
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.

Statistics: Posted by s3a — 2024-01-10 06:24 — Replies 0 — Views 847



Viewing all articles
Browse latest Browse all 3260

Trending Articles