Replies: 2 comments
-
For more complex cases try a look at files in A single file can normally contain multiple boots but in this case journalctl seems to have started a new file after the crash; you can see that the second file has not reached the maximum size and that his last modification time 11:45 matches the (wrong) time of reboot after the crash.
You can read a single
cc: @poettering |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Summary: in case of time warps, always look at A SINGLE BOOT AT A TIME thanks to the
journalctl -b -N
option. Otherwise journalctl will (wrongly?) sort log statements based on their (possibly wrong) timestamps and interleave logs from different boots, which is extremely confusing.See example below where the start of the second boot with wrong time 11:45:22 was moved up and interleaved with the previous boot.
Context: for testing purposes we usually disconnect laptop batteries in the lab. This allows power-cycling them remotely. With most laptops this is OK but with some power cycling can cause "time warps" which make the output of journalctl (and of probably other similar logging systems) extremely confusing.
Desktop systems with a coin cell battery are not affected.
Every journalctl record has a __BOOT_ID field which unlike timestamps is always correct. You can see the __BOOT_ID of each line using
journalctl -o json-pretty
journalctl prints a
-- Reboot --
everytime the __BOOT_ID changes. So-- Reboot --
does NOT mean there was actually a reboot! In the example below you can see that there are many more-- Reboot --
lines than actual reboots.You must mentally translate
-- Reboot --
into: now showing you some logs from a different boot. It's normally because of a reboot but not always.The -b option selects a single __BOOT_ID which is great because the __BOOT_ID is always correct.
Caveat: I do not guarantee that using -b is a silver bullet and it solves every time warp issue but in this example below it is a silver bullet and it does get rid of the interleaving completely.
Warning you cannot fully trust the timestamps in the output of
journalctl --list-boots
either. But again, thanks to the magic of the _BOOT_ID the number of boots in--list-boots
is correct.PS: I wonder why boots and records don't have a simple sequence number.
PS: fun read: https://www.newyorker.com/tech/annals-of-technology/the-thorny-problem-of-keeping-the-internets-time
Beta Was this translation helpful? Give feedback.
All reactions