I would like to run certain aliases and simple commands when system shuts down or reboots or when I simply log out of system. This would help a lot as I usually forget about shutting down vagrant ( vagrant halt ) and some other terminal commands. Do we have some kind of bash files or scripts so I can achieve this on Ubuntu 14.04.
Asked
Active
Viewed 1,459 times
1 Answers
-1
Runlevel 0 corresponds to shutdown, and Runlevel 6 corresponds to reboot.
The /etc/rc[0-6].d/ directories contain scripts that are executed when a particular runlevel is initiated.
So you can write a script that contains commands to shutdown various processes, and store that script in /etc/rc0.d/K99_yourscript and make it executable. This will run your script at shutdown. Copy the script over to /etc/rc6.d/K99_yourscript to have it execute on reboot as well.