[systemd-devel] Help with running a script at shutdown and make it run first before other services

David Elie-Dit-Cosaque deliedit at redhat.com
Fri Dec 6 22:16:29 UTC 2024


Hi All,

I am trying to create a systemd service that would execute a script at
shutdown before any other services start receiving shutdown notifications.
I came up with this:

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/usr/bin/true
ExecStop=/usr/local/bin/myscript.sh
[Install]
WantedBy=multi-user.target

The script does run after shutdown is initiated but since it relies on
other services which are also shutting down, it fails. Is there a way to
order the shutdown so that  myscript.sh is completed first before
continuing with the shutdown?

Thanks!
David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20241206/2a4cfd5f/attachment.htm>


More information about the systemd-devel mailing list