script to log power on and poweroff
Clint Byrum
clint at ubuntu.com
Wed Nov 23 16:41:30 UTC 2011
Excerpts from Carlos Becker's message of Wed Nov 23 06:52:01 -0800 2011:
> Hello,
>
> For time tracking I need a script that simply logs
> the time when I switch on my computer and when I switch it off again.
>
> I am using this script /etc/init/logmytime.conf
>
>
> description "logmytime"
>
> start on runlevel [0623]
>
> post-start script
> date >> /home/me/logmytime.log
> end script
>
> But this is only logging when I start my PC,
> shutdown is not logged. I suspect that probably
> the filesystem is allready unmountet when the script runs on shutdown.
>
> How can I do it right ?
This would work:
start on starting rc RUNLEVEL=[0623]
Wouldn't it be easier to just use wtmp though?
Try the 'last' command.. it probably covers all your needs.
More information about the upstart-devel
mailing list