-   Linux - General (
-   -   [FYI] "last -f <old wtmp> -x reboot shutdown" incorrect for last reboot and shutdown (

catkin 03-25-2010 06:07 AM

[FYI] "last -f <old wtmp> -x reboot shutdown" incorrect for last reboot and shutdown
Hello :)

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    Sun Mar  7 15:35 - 03:02  (11:27)
reboot  system boot    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    Sun Feb 21 12:39 - 13:20  (00:40)
reboot  system boot    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    Fri Mar 12 07:42          (01:54)
shutdown system down    Fri Mar 12 01:31 - 09:37  (08:05)

wtmp begins Thu Mar 11 08:25:26 2010
reboot  system boot    Wed Mar 10 14:12        (15+01:42)
shutdown system down    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.



catkin 03-25-2010 11:52 PM

Taking this thread off the zero reply list.

All times are GMT -5. The time now is 07:18 PM.