[systemd-devel] use RTC date/time to set system date time

Michał Zegan webczat_200 at poczta.onet.pl
Mon Mar 1 16:22:02 UTC 2021



W dniu 01.03.2021 o 17:19, Lennart Poettering pisze:
> On Mo, 01.03.21 17:09, Michał Zegan (webczat_200 at poczta.onet.pl) wrote:
> 
>>>> There are problems with log timestamps when you do that, and it is
>>>> probably why it was not done.
>>>> I am wondering if the only correct way isn't to do it in initramfs (if
>>>> it's systemd) before starting the journald, so that first saved logs
>>>> have correct timestamps?
>>>
>>> The earlier you have a "correct" clock the better.
>>>
>>> But I mean, journald won't lie to you: the log messages are associated
>>> with the timestamps that were accurate at the moment they are
>>> generated. But of course, if your clock sucks then they'll look
>>> differently than you might expect.
>> However the initial log entries in journald are taken from dmesg and
>> dmesg timestamps are relative, so setting the clock before journald
>> first starts should make journal times correct.
>> Or I am wrong?
> 
> kmsg comes with monotonic timestamps only. journald stores that away
> but generally uses its own acquired timestamps, since it needs to
> guarantee monotonicity and things.
> 
> But do note that journald typically runs in the initrd already.
Yes, my idea was to wait for time *in initramfs* before journald. Like
force the rtc driver to land in initramfs, then just load it, set time
if kernel doesn't, and then start journald.
> 
> Lennart
> 
> --
> Lennart Poettering, Berlin
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210301/eb951809/attachment-0001.sig>


More information about the systemd-devel mailing list