0

I have a standalone debian-based system that -- for the simplicity -- can be taken as not having RTC. The system clock can be set during operation, both forwards and backwards.

I thought that journalctl should order log lines based on boot ids and sequence number if they are available, but unfortunately it seems it is not true, at least, I get journalctl outputs like this:

...
-- Boot 1b6fb8b971ce4d5f9ccc7f71b19f496d --
Jan 05 18:07:40 lumon myapp: ...
-- Boot e0f8203b0c18497ba94fd121eb1c4af9 --
Jan 05 18:07:41 lumon myapp: ...
Jan 05 18:07:41 lumon myapp: ...
-- Boot 1b6fb8b971ce4d5f9ccc7f71b19f496d --
Jan 05 18:07:42 lumon myapp: ...
Jan 05 18:07:42 lumon myapp: ...
-- Boot e0f8203b0c18497ba94fd121eb1c4af9 --
Jan 05 18:07:42 lumon dhclient[507]: DHCPDISCOVER on net0 to 255.255.255.255 port 67 interval 13
Jan 05 18:07:42 lumon sh[507]: DHCPDISCOVER on net0 to 255.255.255.255 port 67 interval 13
Jan 05 18:07:42 lumon myapp: ...
-- Boot 1b6fb8b971ce4d5f9ccc7f71b19f496d --
Jan 05 18:07:42 lumon myapp: ...
Jan 05 18:07:43 lumon myapp: ...
-- Boot e0f8203b0c18497ba94fd121eb1c4af9 --
Jan 05 18:07:43 lumon myapp: ...
...

As you can see, lines from different boots are interleaved.

This is a clear indication of the issue, but of course, if I look only one boot (by merging all the related chunks) then lines are in bad order, i.e., not in the order of creation, too.

Is there a way to get back my log lines in creation order?

5
  • "The system clock can be set during operation, both forwards and backwards" - no ideal at all. Can you fix that so that at least it doesn't step backwards Commented Jan 18, 2024 at 12:37
  • It is a system design limitation as it mentioned. Commented Jan 18, 2024 at 14:35
  • Doesn't mention that at all. You just say your system has no RTC. There are tools that will set the RTC as part of the boot process to the last known good value. Obviously given a solution like that the clock then has no need to go backwards Commented Jan 18, 2024 at 15:22
  • What about forcing ForwardToSyslog=yes in /etc/systemd/journald.conf so that your logs can still stand and be cat-ed as good old (I mean in creation order) logs in /var/log ? (you'll need to have the rsyslog service running) Commented Jan 27, 2024 at 11:58
  • Yes, this is one option I can consider. Just I wonder if it is indeed an insoluble problem inside systemd-journald... Commented Feb 12, 2024 at 16:18

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.