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:
#!/bin/bash
date >> ~/mydatausage.txt
ifconfig -a >> ~/mydatausage.txt
at the time of shutdown.
How can I run this script at shutdown, as root?
Best Answer
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