I would like to know the time when a linux box has booted up last year. Is there any way to ask the computer at which time it has been booted up ?
thanks.
I would like to know the time when a linux box has booted up last year. Is there any way to ask the computer at which time it has been booted up ?
thanks.
Try
uptime
orlast -x
.Last should give you the boot times, looking for the reboot or boot usernames. If need be you may need to find and use the flag that lets you load the older last logs
Perhaps
ps aux | grep init
gives you detailed enough information? After a long(ish) uptime it shows you the date the init process was started.If that's not accurate enough, see /proc/stat and the btime value there. It's the Unix time in seconds when the system was last booted up. To parse it, use your favourite date manipulating tool, for example Perl Date::Manip module:
grep btime /proc/stat | cut -d ' ' -f2 | perl -MDate::Manip -lane 'printf "%s\n", UnixDate(ParseDateString("epoch $_"), "%c");'
In my test server that returns
Mon Jul 19 15:45:12 2010
Which is the last the the server was restarted.
On Linux, there's the
uprecords
utility that records all youruptime
history. You have to install it first to start recording your uptimes though (i.e. it won't show your past uptimes).