Skip to content

Save/Restore the current time to/from a local file #2309

Description

@Stebalien

When the a system loses power and has no CMOS/RTC battery, time can go backwards. Loss of time can cause issues with NTS certificate checks (as documented in #1428) but going backwards in time can wreak havok across the system, causing timers/cron jobs to start when they shouldn't, backups to run at the wrong time, etc.

As of systemd/systemd#20142, systemd-timesyncd:

  1. Periodically (and after every sync) saves the current time to /var/lib/systemd/timesync/clock.
  2. On start, it restores this time if the time reported by the RTC is in the past (relative to this file).
  3. The systemd-timesyncd.service unit is ordered before time-set.target and only reports that it is "ready" after it restores this time. This prevents delays timers from running until the time has been restored.

It would be great if ntpd-rs could do the same thing.

This can just as easily be done as a separate bash script, but solving this within ntpd-rs would be a step towards fixing #1428 (it would let ntpd-rs detect when time has gone backwards).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions