1

I've been looking through various pages on this site and others looking for a way to execute a script on shutdown and restart, but none of them are working for me.

I've tried placing bash scripts in /etc/init.d/ and linking them to /etc/rc0.d/ and /etc/rc6.d/, but they won't run on shutdown or restart. I've also tried using the update-rc.d command to create new services, but

  1. they don't work, and
  2. they don't even create a new link in the rc?.d folders.
zx485
  • 2,249
  • 11
  • 24
  • 34
Alex S
  • 111
  • 2
  • sysvinit used /etc/rc*.d/, but sysvinit was long ago replaced by Upstart, which was in turn replaced years ago by systemd. See [How to run a script with systemd right before shutdown?](https://unix.stackexchange.com/questions/39226/) for good advice. – user535733 Oct 15 '19 at 00:22
  • One big problem with using sysvinit scripts for shutdown/restart is that they are easy to (unintentionally) bypass. That's why most housekeeping (like clearing /tmp) occurs at startup instead. – user535733 Oct 15 '19 at 00:28
  • I agree it's a duplicate, and for what it's worth I managed to get it working. Thanks for the help. – Alex S Oct 15 '19 at 01:08

0 Answers0