Question about chrony use in a system without RTC battery
Kris van Rens <[email protected]>
| Newsgroups | gmane.comp.time.chrony.user |
|---|---|
| Message-ID | <CAGSxEQGyFgXRH6bE0kK3opAEV5GG+iqqA-khAHhXD9zLTMei2A@mail.gmail.com> |
Hello! I have a question regarding Chrony use in (Yocto-based) systems that have no RTC battery, or at least a very short-lived one. The devices I'm working with regularly have unstable internet connections, and sometimes lose power all of the sudden (clearing the RTC value). My main goal is to prevent the system time to jump back. My application data recording mechanism assumes time to increase monotonously, and a jump back in time will prevent my application from writing any data. In a case of a temporary poweroff + RTC value loss, I'd rather have an erroneous time indication that disregards the outage time, but at least does not jump back in time. In any normal situation NTP is always enabled and the internet connection is stable, but power outages do happen. I've been testing with Chrony which seems like the right tool for the job. The NTP synchronization works really well, but I can't seem to get the power loss situation covered well. My /etc/chrony.conf looks like this: --- include /etc/chrony.d/00-custom.conf pool 0.pool.ntp.org iburst pool 1.pool.ntp.org iburst pool 2.pool.ntp.org iburst pool 3.pool.ntp.org iburst makestep 1.0 3 driftfile /var/lib/chrony/drift rtcfile /var/lib/chrony/rtc rtcautotrim 1 dumpdir /var/lib/chrony logdir /var/log/chrony log tracking --- The extra configuration file '/etc/chrony.d/00-custom.conf' is empty for now, but lives in persistent memory, the root filesystem is readonly. Of course /var is writable too. I'm using systemd as the startup management system, and have chronyd set to start up with "-s -r": --- $ cat /etc/default/chronyd export OPTIONS='-s -r' --- This will pass the $OPTIONS to the system service file. But I don't really know how to verify this. My observation with power loss simulations is that the system keeps on jumping back in time (~a week). What I do is I break the internet connection such that the NTP synchronization is lost, then pull the power plug, re-insert the power plug (but leave the internet connection broken). As far as I could read in the documentation, Chrony should be able to pick up the last modification time from the driftfile, but this file is not always there. Is there some other way to force resetting the time at boot to the last modification time until NTP synchronization is restored? Any help is appreciated, thanks in advance! Kind regards, Kris van Rens -- To unsubscribe email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org with "unsubscribe" in the subject. For help email chrony-users-request-kWFZVVI9zxvPqho9SqqRMmD2FQJk+8+b@public.gmane.org with "help" in the subject. Trouble? Email [email protected]