[systemd-devel] Testing if timesyncd is synced
Bruno Vernay
brunovern.a at gmail.com
Wed Feb 20 13:49:01 UTC 2019
Isn't ntpstat specific to chrony ??
Conversely, `timedatectl timesync-status` will not work even if the
clock is synchro with chronyd.service.
Bruno
On Wed, Feb 20, 2019 at 2:20 PM Mantas Mikulėnas <grawity at gmail.com> wrote:
>
> On Wed, Feb 20, 2019 at 3:01 PM Aurelian Melinte <ame01 at gmx.net> wrote:
>>
>> On 20/02/2019 4:18 a.m., Mantas Mikulėnas wrote:
>>
>> On Wed, Feb 20, 2019 at 10:55 AM Paul D. DeRocco <pderocco at ix.netcom.com> wrote:
>>>
>>> What's the simplest way to test if systemd-timesyncd is currently synced
>>> to the network, from within an embedded application (running with root
>>> privileges)? Is there some single dbus transaction that will give me this
>>> answer?
>>
>>
>> Call adjtimex(2) and check whether buf.status has STA_UNSYNC (should be unset when clock is synchronized).
>>
>> The systemd-timedated helper service (org.freedesktop.timedate1) exposes the same flag as the org.freedesktop.timedate1.NTPSynchronized property on /org/freedesktop/timedate1.
>>
>> (That said, this deliberately won't work if you've configured timesyncd to use "local time" instead of UTC, as timesyncd doesn't want to activate RTC updates in that mode.)
>>
>> timesyncd itself exposes several properties including the actual received NTPMessage, but I'm not sure if it's as good as an explicit indication. It does emit update signals however.
>>
>> --
>> Mantas Mikulėnas
>>
>>
>> Some (old?) systems do not have adjtimex:
>>
>> $ adjtimex
>>
>> -bash: adjtimex: command not found
>
>
> I wasn't talking about the command-line tool, but about the Linux kernel syscall.
>
> --
> Mantas Mikulėnas
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
Bruno VERNAY
More information about the systemd-devel
mailing list