[systemd-devel] time-sync.target

Luke Shumaker lukeshu at lukeshu.com
Wed May 31 01:36:52 UTC 2017


On Tue, 30 May 2017 11:57:00 -0400,
Pietro Paolini wrote:
> Hi everybody,
> 
> I am trying to configure my systemd to run my service *after* the
> timesyncd service is synchronized with the NTP server, unfortunately
> adding the "After=time-sycd.target" does not work as I can't see any
> change in the behavior - my service is started immediately anyway.
> 
> Reading here https://github.com/systemd/systemd/issues/5097 it looks
> like there is a problem with that target but I am not sure where to
> start from, is it feasible to patch the systemd-timesyncd daemon to
> correct the behavior ?

Yes, this is a problem with timesyncd, and it should eventually be
patched.

The problem with patching it is that without re-thinking something, it
is impossible to have it block time-sync.target without also risking
systemd-timesyncd.service from timing out.

The only solution that I can think of is to have a second helper
process that can't time out that waits for a signal from timesyncd;
and have that process block time-sync.target.  But, the systemd team
hasn't yet decided if this solution is acceptable to them.

So, anyway, I went ahead wrote such a helper program, and a wrapper
for timesyncd that handles sending the signal.

> As alternative I could write my wrapper around the daemon as done in
> the link reporting the issue, both ways I will need to read
> something enlightening on the matter, would you be able to point me
> into the right direction ?

You should be able to install and use the wrapper that I wrote.
There's nothing specific to my use-case about it.  If you install it,
then the "time-sync.target" should "just work" correctly with
timesyncd.

Of course, in the long-term it would be preferable to patch timesyncd,
instead of having to install separate wrapper to fix the behavior.
But for today, it works.

-- 
Happy hacking,
~ Luke Shumaker


More information about the systemd-devel mailing list