0

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 ?

Alex
  • 26
  • 4
  • why not check with ntp? – stark Apr 15 '21 at 11:06
  • Because sometimes ntp is not available due to the router (ntp port blocked) – Alex Apr 15 '21 at 12:04
  • 1
    If it's blocked hen ntp won't say that it's synchonized. – stark Apr 15 '21 at 13:15
  • Yes but htpdate will get a date and synchronize the system clock. How can I know that it synchronized it ? (I can see it in the logs but there is maybe a better way) – Alex Apr 15 '21 at 13:37
  • `ntpdate` is deprecated. `ntpq` is the query program. – stark Apr 15 '21 at 13:53
  • Actually ntpstat is better – stark Apr 15 '21 at 14:01
  • All I want to know is : Is it possible to get the same info that timedatectl gives "System clock synchronized: yes" when its [htpdate](https://linux.die.net/man/8/htpdate) that synchronized the system clock – Alex Apr 15 '21 at 14:06

1 Answers1

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

Eddy
  • 21
  • 2