2

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.

4 Answers 4

11

Try uptime or last -x.

2
  • Thanks but this gives the actual boot time, what I'm looking for is a list of boot times.
    – Marc Riera
    Aug 16, 2010 at 8:08
  • Yes, that's why I mentioned last -x. Depending on your log rotation policy you might need to provide another wtmp file e. g. last -x -f /var/log/wtmp.1.
    – joschi
    Aug 16, 2010 at 8:26
0

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

0

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.

0

On Linux, there's the uprecords utility that records all your uptime history. You have to install it first to start recording your uptimes though (i.e. it won't show your past uptimes).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .