'How to know if htpdate has synchronized system clock?

On my linux system, I use ntp to synchronize the system clock. I also installed htpdate to synchronize it when ntp is not available.

To know if ntp has synchronized the clock, I call timedatectl that outputs :

System clock synchronized: yes

But this "variable" is not changed when its htpdate that changes the system clock.

Is there a similar way to know if htpdate has set the system clock ?



Solution 1:[1]

htpdate doesn't set the kernel flag used by ntp and timedatectl (yet).

simple way of checking can be done like,

# htpdate example.com
Offset 0.125 seconds

or if your system is in sync, it will return

# htpdate example.com
No time correction needed

Update: in latest master (will be included in version htpdate 1.3.5) the "System clock synchronized: yes" will be set when used with "-x'

https://github.com/twekkel/htpdate

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1