chmod +x yourscript.sh cp yourscript.sh /etc/init.d/ cd /etc/init.d/ update-rc.d yourscript.sh start 20 0 6 . # Runlevel # 0=halt # 6=reboot
Ignore message insserv: warning: script 'yourscript.sh' missing LSB tags and overrides. This warning appears because yourscript.sh format doesn't conform to LSB init script.
Reference
- https://wiki.debian.org/LSBInitScripts
- http://www.linuxquestions.org/questions/debian-26/run-this-command-when-the-computer-shutdown-or-reboot-683851/
- http://en.wikipedia.org/wiki/Runlevel