Discussion:
timesyncd equivalent to ntp-wait
Add Reply
Shawn Johnson
2017-08-08 13:13:42 UTC
Reply
Permalink
Raw Message
I need to be able to start a service only after time synchronization has
occurred. I implemented this as a systemd target with ntpd and ntp-wait
but I can't find an equivalent for timesyncd. I found a couple references
to this problem but didn't find them helpful:

* [Patch from 2014]
https://lists.freedesktop.org/archives/systemd-devel/2014-November/025131.html
* [Github Bug 5097] https://github.com/systemd/systemd/issues/5097

Worst case I guess I could grep the output of timedatectl for "NTP
synchronized" but since that tool knows the state of synchronization It
would seem this information must be available in a more programmatic way.
Any help would be greatly appreciated. Also, if a solution is found how can
I submit changes to the documentation? The systemd-timesyncd.service man
page is pretty weak.
Lennart Poettering
2017-08-09 08:37:34 UTC
Reply
Permalink
Raw Message
Post by Shawn Johnson
I need to be able to start a service only after time synchronization has
occurred. I implemented this as a systemd target with ntpd and ntp-wait
but I can't find an equivalent for timesyncd. I found a couple references
* [Patch from 2014]
https://lists.freedesktop.org/archives/systemd-devel/2014-November/025131.html
* [Github Bug 5097] https://github.com/systemd/systemd/issues/5097
Worst case I guess I could grep the output of timedatectl for "NTP
synchronized" but since that tool knows the state of synchronization It
would seem this information must be available in a more programmatic way.
Any help would be greatly appreciated. Also, if a solution is found how can
I submit changes to the documentation? The systemd-timesyncd.service man
page is pretty weak.
We really should add a concept like this, and this has been on the
TODO list for a while, but so far nobody sat down and actually did
something about this. We'd be happy to take patches for this though...

I figure this could either be implemented via some dbus API, or simply
by doing a touch file thingy: as soon as timesyncd considers the clock
synchronized it could just touch a file in /run/systemd/timesync/ or
so. And the systemd-timesync-wait.service tool could use inotify to
wait for that to appear or so.

Would be happy to take a patch for this!

All patches are best submitted through github, regardless if code or
man page fixes, after all this all is maintained in the same git repo!

https://github.com/systemd/systemd

Lennart
--
Lennart Poettering, Red Hat
Loading...