Ubuntu: How to have a process come first during shutdown sequence?



Question:

I know that, with systemd, any scripts put in /lib/systemd/system-shutdown/ will launch at the very end of a shutdown sequence.

Is there a similar type of thing for scripts that I wish to launch immediately? Without a service file?


Solution:1

As you mentioned in a comment, systemd shuts down services in the reverse order that they are started.

You can create a new target that forces your command to be started last and shutdown first. Then set your system to boot to this new "target" state instead of the "multi-user.target" or "graphical.target".

In your new service, set ExecStop= to be the thing you want to run first on shutdown.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »