Detecting System Restart or Shutdown?

Jordon Bedwell jordon at envygeeks.com
Wed Apr 13 11:31:53 UTC 2011


On 4/13/2011 5:41 AM, waqar afridi wrote:
> Hello Dear List
> 
> Is there any method through which I can Detect that the System was
> recently shutdown or Restarted?
> 
> *Explanation:*
> 
> I am making a utility that will Store some Files on HardDisk. I want the
> utility to Detect if the System
> is newly Booted. If it is, It should delete those Files and Create fresh
> Once.
> 
> Thanx in Advance
> 
> -- 
> *Waqar Afridi*
> 

Use the pseudo user reboot on the last command:
http://manpages.ubuntu.com/manpages/natty/en/man1/last.1.html

In short, "last reboot" command will show each time the system has been
rebooted because the pseudo user reboot "logs in" each time the system
is started, from there you can do as you please with the output.





More information about the ubuntu-users mailing list