Skip to content

Instantly share code, notes, and snippets.

@Ultrabenosaurus
Created January 16, 2015 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ultrabenosaurus/444e48969c05c4035547 to your computer and use it in GitHub Desktop.
Save Ultrabenosaurus/444e48969c05c4035547 to your computer and use it in GitHub Desktop.
add scripts to Ubuntu's shutdown process
http://askubuntu.com/questions/416299/execute-command-before-shutdown-reboot
To execute a script at shutdown or reboot:
save your script in /etc/rc6.d
Make it executable: sudo chmod +x K99_script
Notes:
- The script in rc6.d must be with no .sh extension
- The name of your script must begin with K99 to run at the right time.
- The scripts in this directory are executed in alphabetical order.
- These instructions cover halt and reboot and I think the symlink convention is more accepted:
- Create a shell executable file with your script in /etc/init.d/ directory.
Since this has to be executed during shutdown or reboot need to create softlinks in /etc/rc0.d/ and /etc/rc6.d
Example:
sudo ln -s /etc/init.d/<your_file> /etc/rc0.d/k99stop_vm
sudo ln -s /etc/init.d/<your_file> /etc/rc6.d/k99stop_vm
sudo chmod a+x /etc/rc0.d/k99stop_vm /etc/rc6.d/k99stop_vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment