1

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?

  • Possible duplicate of http://askubuntu.com/questions/292796/how-to-run-a-script-at-shutdown. However, your 14.04 system uses `upstart` jobs; once you upgrade to a `systemd` oriented system, you need to do things differently. – Jos Jul 24 '15 at 07:09
  • No! i can't able to understand the answer – Buvanesh Kumar Jul 24 '15 at 07:14
  • Perhaps [this](http://ccm.net/faq/3348-ubuntu-executing-a-script-at-startup-and-shutdown#to-execute-a-script-at-shutdown) helps. It is a very simple how-to. – Jos Jul 24 '15 at 07:24
  • alternatively to the above ways (which are the proper an clean ones one is supposed to follow) the dirty path would be moving your `/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
  • possible duplicate of [Execute a script upon logout/reboot/shutdown in Ubuntu](http://askubuntu.com/questions/293312/execute-a-script-upon-logout-reboot-shutdown-in-ubuntu) – kos Jul 24 '15 at 07:35

1 Answers1

2

To execute a script at shutdown:

  1. Put your script in /etc/rc6.d
  2. Make it executable: sudo chmod +x K99_script
  3. 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:

ATR
  • 403
  • 1
  • 5
  • 18