last(1) when invoked as 'last reboot' should show the time and date of reboots. As the man page says: The pseudo-user reboot logs in at reboots of the system, thus ``last reboot'' will give an indication of mean time between reboot. However, with the switch from /var/log/wtmp to /var/log/utx.log this functionality no longer works. How-To-Repeat: I last rebooted about 3 days ago: lucid-nonsense:~/work:% uptime 11:47AM up 3 days, 12:51, 1 user, load averages: 0.05, 0.03, 0.00 ... and utx.log hasn't been recycled during that time: lucid-nonsense:~/work:% ls -l /var/log/utx.log* -rw-r--r-- 1 root wheel 17047 Jun 8 11:41 /var/log/utx.log -rw-r--r-- 1 root wheel 24878 May 31 22:41 /var/log/utx.log.0 -rw-r--r-- 1 root wheel 13741 Apr 30 08:50 /var/log/utx.log.1 -rw-r--r-- 1 root wheel 27886 Mar 31 22:52 /var/log/utx.log.2 but no information about system reboots is shown by 'last reboot' lucid-nonsense:~/work:% last reboot wtmp begins Fri Jun 1 06:14:46 BST 2012 With the patch below, the result is: lucid-nonsense:~/work:% /usr/obj/usr/src/usr.bin/last/last reboot boot time Mon Jun 4 22:58 shutdown time Mon Jun 4 22:54 boot time Sun Jun 3 09:43 shutdown time Sun Jun 3 09:39 wtmp begins Fri Jun 1 06:14:46 BST 2012
Responsible Changed From-To: freebsd-bugs->ed I'll take it.
Linux and Solaris put "reboot" in the username field for BOOT_TIME and SHUTDOWN_TIME at least, the type of event going into a different field. This may not be strictly necessary, but makes it such that the man page text remains correct. The attached patch only makes "reboot" special as a filter. The patch looks good to me otherwise.
*** Bug 183962 has been marked as a duplicate of this bug. ***
A commit references this bug: Author: ed Date: Tue Jul 21 10:52:07 UTC 2015 New revision: 285742 URL: https://svnweb.freebsd.org/changeset/base/285742 Log: Unbreak "last reboot". According to the last(1) man page, the "reboot" pseudo-user should print all system reboot entries. This got broken by the utmpx import, as records are typed. Re-add support for "last reboot" by specifically matching against SHUTDOWN_TIME and BOOT_TIME records. PR: 168844 Submitted by: matthew@ MFC after: 1 month Changes: head/usr.bin/last/last.c
A commit references this bug: Author: ed Date: Thu Aug 20 08:34:14 UTC 2015 New revision: 286952 URL: https://svnweb.freebsd.org/changeset/base/286952 Log: MFC r285742: Unbreak "last reboot". According to the last(1) man page, the "reboot" pseudo-user should print all system reboot entries. This got broken by the utmpx import, as records are typed. Re-add support for "last reboot" by specifically matching against SHUTDOWN_TIME and BOOT_TIME records. PR: 168844 Submitted by: matthew@ Changes: _U stable/10/ stable/10/usr.bin/last/last.c