Further to this LQ thread
which Tinkster solved by suggesting the last command (thanks Tinkster) I have been exploring last -x reboot
and have found that the reported duration is incorrect for the last reboot and shutdown when a old wtmp file is used. Not having a record for the following shutdown, last assumes that the system has been up until the current time and similarly for the shutdown.
The output comes in time order, latest first, each line showing the time of the reboot and the uptime from then to shutdown. Using last -x reboot shutdown
to show the shutdown time, here's an illustration
shutdown system down 220.127.116.11-smp Sun Mar 7 15:35 - 03:02 (11:27)
reboot system boot 18.104.22.168-smp Sun Mar 7 09:35 (05:59)
09:35 until 15:35 is 05:59.
When the uptime exceeds 24 hours it is shown as (<days>+<hours:minutes) like this
shutdown system down 22.214.171.124-smp Sun Feb 21 12:39 - 13:20 (00:40)
reboot system boot 126.96.36.199-smp Sat Feb 20 09:39 (1+02:59)
09:39 until 12:39 the next day is 1 day 02:59.
The time in parentheses at the end of the shutdown lines is normally the time until the next shutdown.
So far so good. The incorrect output is for the last reboot and shutdown of an old wtmp file. Here's the output of last /var/log/wtmp -x reboot shutdown; last -f /var/log/wtmp.1 -x reboot shutdown
reboot system boot 188.8.131.52-smp Fri Mar 12 07:42 (01:54)
shutdown system down 184.108.40.206-smp Fri Mar 12 01:31 - 09:37 (08:05)
wtmp begins Thu Mar 11 08:25:26 2010
reboot system boot 220.127.116.11-smp Wed Mar 10 14:12 (15+01:42)
shutdown system down 18.104.22.168-smp Wed Mar 10 12:41 - 15:54 (15+03:13)
The boot started at "Wed Mar 10 14:12" which had an actual uptime of 1 day 11:20 is reported as 15 days 03:13 which is the time from then until the last -f /var/log/wtmp.1 -x reboot shutdown
command was issued. The time from shutdown to shutdown is similarly affected.