Monday, 7 March 2011

a simple perl timer scripts


here is some simple code to shutdown the computer at a particular probably may have more better script then this. or even write simple shell script. but here is what i use.

 $cont = "075500"; // time at which the computer must halt 07:55:00  
 $var = `date +%H%M%S`;//initializing the $var and getting the current time from the shell command and storing the value in $var  
 if($var == $cont) //checking the values  
 `init 0`//signal command to shut down the computer.  
 `sleep 1`;  
 $var = `date +%H%M%S`;//after every second getting the current time and matching the value in a infinite while loop.  

as halt command need super user privilege. you need to run the script as root or sudoer 

No comments:

Post a Comment