The new binary logs on Linux operating systems do not work in the way that the old binary logs did.
The old binary logs were /var/log/wtmp
and /var/log/btmp
. At system bootstrap an entry would be written to wtmp
with the username reboot
, and at shutdown an entry would be written to wtmp
with the username shutdown
. Finding the times that the system was rebooted was a matter of using the last reboot
and last shutdown
commands to print out these entries.
The new binary logs are the systemd journal, and they do not have such entries.
Instead, every journal record has a field named the boot ID. You can see this with the -o verbose
option to journalctl
. A boot ID is generated by the kernel at bootstrap, and systemd-journald
applies the current boot ID, taken from the kernel, to every log record as it is adding it to the journal.
To implement the list-boots
functionality, journalctl
scans the entire journal, reading the timestamps and boot IDs of every record, and noting the earliest and latest timestamps associated with each unique boot ID.
Thus if parts of the journal are purged, or conversely stick around overlong, the apparent boot and shutdown times reported by journalctl
will differ wildly from the actual boot and shutdown times.
/run/utmp
is a table of terminal login records, with special entries for bootup and shutdown. These entries are read by uptime
and who -b
. They are written by programs such as systemd-update-utmp
, an analogue of the FreeBSD utx
command, which are run as parts of the startup and shutdown procedures. They are not run first or last, as the relevant services are not (and indeed cannot be) ordered absolutely first or last. There may be journal entries with the relevant boot ID that precede the time that systemd-update-utmp reboot
is run, and similar journal entries that postdate the time that systemd-update-utmp shutdown
is run.
Further reading