I know adding script in startup time. Is it possible, adding script in system shutdown time? For an example Whenever a user, shutdown their PC, I want a history -c command will run in the background so that the user's previous worked commands can be erasing in the terminal. Is it possible?
Asked
Active
Viewed 350 times
1 Answers
2
To execute a script at shutdown:
- Put your script in
/etc/rc6.d
- Make it executable:
sudo chmod +x K99_script
- Notes:
- The scripts in this directory are executed in alphabetical order.
- The name of your script must begin with
K99
to run at the right time.
For more info please see this link. Hope this helps.
Sources:
upstart
jobs; once you upgrade to asystemd
oriented system, you need to do things differently. – Jos Jul 24 '15 at 07:09/sbin/shutdown
to e.g./sbin/shutdown.orig
and replace it with whatever script you like and add the execution of the original shutdown command at the end of said script. I still would not recommend it, but it is a possibility..... – FelixJN Jul 24 '15 at 07:32