3

I want to track my time at the desk. As a first approximation, I guess tracking the time the computer is turned on, and then subtracting the relatively constant lunch break should do.

How can I execute a script at the early stages of shutting down of my Debian jessie?

Vorac
  • 3,077

2 Answers2

2

13ushm4n's answer shows how to execute a script during shutdown, but if you want to track the amount of time your computer is on, there are tools for that. On Debian, you could use uptimed; it will automatically keep track of the total amount of time your computer is on and off.

Stephen Kitt
  • 434,908
0

Make a script in /etc/init.d/ (make sure that it is executable - chmod ugo+x /etc/rc0.d/S##your_script and make a symbolic link in /etc/rc0.d/ - ln -s /etc/rc0.d/S##your_script /etc/rc0.d/S##your_script_symbolic_link ).

rc0.d is shutdown, if you want restarts too then make the symling in rc6.d as well.

13ushm4n
  • 130