On 29/06/2024 01:49, Stefan Monnier wrote:
But note that when we wake up ntpsec is already running
It should be possible to stop the NTP daemon on suspend (or hibernate)
and start it on resume.
I think, what you are truing to achieve is doable. I do not agree with
Greg. The question is what is already implemented and how much scripting
is required to make it working reliably.
I would start from replacing the RTC battery though.
Next I would search systemd-timesyncd and systemd-datetimed, chrony,
ntpsec docs and sources for relevant configuration options,
configuration files and function calls. Switching to another NTP daemon
may save your time required for scripting and configuring your system.
The last part is adding boot/shutdown and suspend/resume hooks and a
periodic task to maintain timestamp when hardware clock was set last
time. Perhaps the tricky part is to ensure that the NTP daemon or some
other system service does not set RTC without notifying your scripts.
My expectation is that events when RTC is updated, but the corresponding
timestamp is not (or vice versa) may be made rare enough. So precise
enough time may be restored on boot or on resume in most cases and NTP
can handle remaining ones.