zerberra has asked for the wisdom of the Perl Monks concerning the following question:
Problem is it does not enter into sub SHUTDOWN when computer shutdown happens. Could you please help me with this.use strict; my($startupTime) = time; # Setup system signal handlers $SIG{'TERM'} = 'SHUTDOWN'; $SIG{'INT'} = 'SHUTDOWN'; while(1) { sleep(10); } # Signal handler for SIGTERM sub SHUTDOWN { my($shutdownTime) = time; my($duration) = $shutdownTime-$startupTime; # Write out the shutdown time open(OUT, ">>$filename"); # Note: $$ is the process id for this script print OUT formatTime($shutdownTime)." Shutdown Uptime: ".formatDu +ration($duration)."\n"; close OUT; exit(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Uptime daemon
by afoken (Chancellor) on Jul 14, 2012 at 04:52 UTC | |
|
Re: Uptime daemon
by bulk88 (Priest) on Jul 11, 2012 at 16:57 UTC |