2

I'm running a distributed computer setup with one machine as time server for the other so the two are in sync to the accuracy of a few ms.

I followed answers on this question: How do I setup a local NTP server?

I was able to setup successfully, but I want to know if there is a way to query ntp or any other program and know the time difference between the two machines?

1 Answer 1

4

The command ntpq -np will output information about time difference between your NTP server and the sources it is synchronizing to (I'm not sure if this is exactly what you want). If you omit -n parametr (ie. ntpq -p) it will display hostnames instead of IP addresses (slightly slower, as it has to do DNS lookups).

The command ntpdate -q <address> will output information about time difference between your machine and the time source specified in <address>. The -q parametr is important, as without it ntpdate will try to sync time to the specified machine instead of just outputting the difference. It is possible that you need to type full path to ntpdate (eg. /usr/sbin/ntpdate) if running from non-root user.

(ntpq should be installed with ntp package, ntpdate is a separate package so you have to install it if it's not already installed)

4
  • Hey raj, thanks for your answer, I received following output: server 10.42.0.199, stratum 16, offset 143905128.738459, delay 0.07806 11 Feb 22:13:36 ntpdate[1501]: no server suitable for synchronization found The offset seems correct, but why does it complain no server suitable for synchronization found? Thanks!
    – jash
    Sep 3, 2020 at 6:24
  • stratum 16 means that machine 10.42.0.199 is not synchronized to any time source - therefore "no servers suitable for synchronization", because NTP protocol refuses to synchronize time to a source that is not synchronized itself.
    – raj
    Sep 3, 2020 at 11:32
  • True, when I connected the server to the internet, the client stopped complaining and it shows stratum 2. I'd like to read more about NTP, could you share a link which has all the information about it?
    – jash
    Sep 3, 2020 at 11:47
  • Well... I'm not sure about the link, I learned most things just by working with NTP... but maybe you could start with the NTP FAQ: ntp.org/ntpfaq
    – raj
    Sep 3, 2020 at 12:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .