[Bug 1563025] Re: 'last' command output is wrong
Richard Hickling
1563025 at bugs.launchpad.net
Sun Feb 2 11:36:17 UTC 2025
Hey, I'm not sure if this is a general fix, but it fixes for me locally:
--- a/login-utils/last.c (revision before change)
+++ b/login-utils/last.c (revision with change)
@@ process_wtmp_file(...) switch statement:
- case BOOT_TIME:
- strcpy(ut.ut_line, "system boot");
- quit = list(ctl, &ut, lastdown, R_REBOOT);
- lastboot = ut.ut_tv.tv_sec;
- down = 1;
- break;
+ case BOOT_TIME:
+ strcpy(ut.ut_line, "system boot");
+ /* If this boot record is older than a later boot event and no shutdown time has yet been recorded,
+ skip printing it so that it doesn't erroneously show "still running". */
+ if (lastboot != 0 && ut.ut_tv.tv_sec < lastboot && lastdown == currentdate)
+ break;
+ quit = list(ctl, &ut, lastdown, R_REBOOT);
+ lastboot = ut.ut_tv.tv_sec;
+ down = 1;
+ break;
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to util-linux in Ubuntu.
https://bugs.launchpad.net/bugs/1563025
Title:
'last' command output is wrong
Status in util-linux package in Ubuntu:
Confirmed
Bug description:
Xubuntu 15.10
util-linux 2.26.2-6ubuntu3
The output of 'last reboot' is wrong. It says 'reboot' is 'still
running' when it shouldn't be, and then arbitrarily 'reboot' stops
running, causing strange lines such as:
reboot system boot 4.2.0-30-generic Tue Mar 22 21:25 - 22:59
(2+01:33)
This line shows that 'reboot' was logged in from 9:25pm to 10:59pm on
the same day, but the total login time was 2 days, 1 hour and 33
minutes.
'reboot' can be 'still running' multiple times simultaneously.
I've attached the results of these commands:
last reboot
last -f /var/log/wtmp.1 reboot
last
last -f /var/log/wtmp.1
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1563025/+subscriptions
More information about the foundations-bugs
mailing list