Run script at shutdown/reboot with systemd
5,530
Just copy / link the script into your /etc/init.d/rc0.d (HALT) and /etc/init.d/rc6.d (reboot) directories, and make sure it's name is prefixed with: "K20"
Related videos on Youtube
Author by
Wolfizen
Updated on September 18, 2022Comments
-
Wolfizen over 1 year
I would like to run a script file when the system is called for shutdown/ reboot from 'reboot' and 'shutdown' commands. And if possible, also hard shutdowns like 'init 0' or 'poweroff'. How would I go about doing that? A config file or command would be nice. I use
systemd
instead ofinitscripts
. -
Wolfizen over 11 yearsI use systemd instead of initscripts. Know a different way to do that without using initscripts? Sorry that wasnt in my post
-
arober11 over 11 yearsThe How Do I Convert A SysV Init Script Into A systemd Service File? page explains the basics, just add the appropriate WantedBy= targets to your service file e.g. [Install] WantedBy=final.target / halt.target / shutdown.target
-
arober11 over 11 yearsFor examples see: archlinux - systemd/Services