I am using Debian wheezy. My problem is, I am using a limited 2.5 GB net connection and would like to capture my usage before shutting down. My idea is simply running a script as:

date >> ~/mydatausage.txt
ifconfig -a >> ~/mydatausage.txt

at the time of shutdown.

How can I run this script at shutdown, as root?


According to the following instruction


you need to put the script in /etc/init.d/ and make a symbolic link in /etc/rc0.d/ this corresponds to the shutdown runlevel and if you want to execute the script when rebooting then make a symbolic link in rc6.d. If you list the folder rc0.d then you will see the script starts with S or K. S come from Start if you want to run script and K come from Kill if you want to stop script

  • thanks for your answer ,can you improve the answer by direct instructions.
    – rɑːdʒɑ
    Nov 3 '13 at 5:23
  • It seems that this solution does not work anymore (I'm using Debian 8.7) Apr 12 '17 at 14:14

Put the script in /etc/rc0.d/ directory, make sure it has execute permissions, and follow the naming convention S*

In your case, you can save your above script in a file at /etc/rc0.d/S00myscript & make sure it is executable by running chmod +x /etc/rc0.d/S00myscript

  • can you improve the answer by direct instructions.
    – rɑːdʒɑ
    Nov 3 '13 at 5:23
  • Done. You can try the instructions now. Nov 3 '13 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.