Perlfunc: get_uptime() 2007-10-03 04:25pm
Simple code to get the current uptime in days.
sub get_uptime {
open(FILE,'/proc/uptime');
my $line = ;
close FILE;
# The first value is seconds of uptime, not sure about the second
my ($seconds,$foo) = split(/\s+/,$line);
# Convert seconds to days
my $ret = int($seconds / (3600 * 24));
return $ret;
}




