[systemd-devel] timesyncd on systems without battery
Dan Tihelka
dtihelka at gmail.com
Fri Jan 15 09:36:34 UTC 2021
Hallo,
thank you for your advice. Option 1 seems to work without problems now.
DT
Dne pondělí 4. ledna 2021 16:36:16 CET, Lennart Poettering napsal(a):
> On So, 03.01.21 10:39, Dan Tihelka (dtihelka at gmail.com) wrote:
> > Hello,
> > I run systemd on a NAS without internal-clock-holding battery, so I think
> > that the systemd-timesyncd sets the time to the last known value after
> > restart and syncs it from the network when on-line. Is it right?
>
> Yes.
>
> > Now, I have a shutdown timer unit, which powers the NAS off at the given
> > time. However, sometimes (about 50% of cases), when the device is
> > powerd-on, it switches off immediately. When switched-on again, it boots
> > as
> > expected.
>
> Why does it do so, because the clock is incorrectly set?
>
> > The question is, is there a way of fixing the issue? I have tried to add
> > sleep to skip to the next minute, but unsuccessfully.
>
> Two options:
>
> 1. Consider explcitly ordering your timer unit after
> "time-set.target". (This will be done implicitly starting with the
> upcoming release of systemd, see
> fe934b42e480473afba8a29a4a0d3d0e789543ac). THis effectively means
> timesyncd has to finish initialization before the timer is
> started, and that in turn means the clock is roughly monotonic for
> all calculations of the calendar time of the timer unit.
>
> 2. Consider enabling "systemd-time-wait-sync.service", which is a
> small service that blocks until the clock is synchronized. Calendar
> based timer units are implicitly ordered after it, once
> enabled. This means the timers will only start once the clock is
> synced to some network reference clock. This is a much stronger
> option, but means the boot process will be delayed based on network
> availability.
>
> Coincidentally we documented this recently in more detail, see git
> commit b149d230ea23c14bac2dfe79c47e58782623200f which also will be in
> the next release.
>
> Lennart
>
> --
> Lennart Poettering, Berlin
More information about the systemd-devel
mailing list