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"

FYI: http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts

Share:
5,530

Related videos on Youtube

Wolfizen
Author by

Wolfizen

Updated on September 18, 2022

Comments

  • Wolfizen
    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 of initscripts.

  • Wolfizen
    Wolfizen over 11 years
    I use systemd instead of initscripts. Know a different way to do that without using initscripts? Sorry that wasnt in my post
  • arober11
    arober11 over 11 years
    The 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
    arober11 over 11 years
    For examples see: archlinux - systemd/Services