Chrony sets system time but does not sync RTC

4.2k views Asked by At

I have configured Chrony with rtcsync flag, which SHOULD "Enable kernel synchronization of the hardware real-time clock (RTC)", but that is not the case.

Chrony sets the system time correctly with ntp, but the RTC is untouched, and i can't seem to find out why that is. My guess is that the kernel doesn't recognize Chrony's request to sync the RTC, but that is just a guess.

Versions
Kernel: 4.19
Chrony: 3.5

UPDATE:

It appears that the external RTC is registered after the kernel tries to access it and this prevents syncing the RTC with the NTP synced system time. from dmesg:

...
[    6.317060] hctosys: unable to open rtc device (rtc)
...
[   14.303503] rtc-ds1307 9-0068: registered as rtc0
...

I've done a temporary workaround by adding a cronjob that updates the hwclock every 10 minutes.

1

There are 1 answers

2
Alexandre Belloni On

To get rtcsync working, you have to set the RTC_SYSTOHC and RTC_SYSTOHC_DEVICE kernel option properly as this simply asks the kernel to sync the system time to the RTC. It does so approximately every 11 minutes.

However, a better way of doing that is to use rtcfile (and rtcdevice) in that case, chrony will handle the RTC. It will even compute the RTC drift that could then be corrected if the RTC supports a trimming mechanism.