[olug] Uptime to boot date

Quinn Coldiron qcoldir at nmhs.org
Tue Oct 29 17:59:48 UTC 2002


Perl to the rescue...

Boot date and time:
6/23/2001 09:21:09


Here is the perl script:

#!/usr/bin/perl
use Date::Calc qw(:all);

# put the values from the uptime command here:
$Udays = 0 - 493;
$Uhours = 0 - 2;
$Usec= 0 - 41;


($Tyear,$Tmonth,$Tday, $Thour,$Tmin,$Tsec) = Today_and_Now();

($year,$month,$day, $hour,$min,$sec) =
Add_Delta_DHMS($Tyear,$Tmonth,$Tday, $Thour,$Tmin,$Tsec,
$Udays,$Uhours,$Usec,"00");

$hour = sprintf("%02d",$hour);
$min = sprintf("%02d",$min);
$sec = sprintf("%02d",$sec);

print "$month/$day/$year $hour:$min:$sec\n";




On Tue, 2002-10-29 at 11:42, Dave Hull wrote:
> On Tue, 29 Oct 2002, Dave Hull wrote:
> 
> > Hm, not sure how to do that, but you could use this:
> > 
> > [~]$ last | grep -i boot
> 
> Come to think of it, this won't do you any good if you're logs are rotated out 
> before your server is rebooted. If you've got /var/log/dmesg, you could check 
> the date of that file to get a close approximation of the last boot time.
> 
> Good luck.
> 
> -- 
> Dave Hull
> http://insipid.com
> 
> He who despises himself nevertheless esteems himself as a self-despiser.
> 		-- Friedrich Nietzsche
> 
> 
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
-- 




More information about the OLUG mailing list