23

I have ntpd running on a box. I want to see how the time on the box compares to the time retrieved from ntp.ubuntu.com. Is there an easy way to do this?

  • I take it you just want to see the time there and not actually change your computer's time to match it? – DerfK Jan 10 '11 at 20:37
  • Yep, that's right. – John Bachir Jan 10 '11 at 20:50
16

ntpq -p ntp.ubuntu.com

From man ntpq:

...
-p     Print  a list of the peers known to the server as well as a summary of their state. This is equivalent to the peers interactive command.
...

Edit: The host is timing out right now. ntpq -p pool.ntp.org will return a valid result.

  • 2
    ntpdate is deprecated so it's best to get in habit of using ntpq instead. However I still use ntpdate all the time myself, old habits die hard. – Phil Hollenback Jan 10 '11 at 20:43
  • 1
    @Phil Hollenback : ntpdate may be "deprecated", but it works. ntpq -p often does not. Possibly because ISPs are blocking it? Or because of the server configuration? – mivk Jan 2 '16 at 23:54
  • 1
    @mivk "Possibly because ISPs are blocking it" This makes no sense. It's all the same NTP protocol. – Jonathon Reinhart Jan 13 '16 at 15:06
  • 10
    @mivk @Jonathon actually, ntpq -p is not asking for time, it's asking for a list of peers and other vars. If the server has a noquery restriction it will timeout. – GnP Apr 21 '16 at 19:10
  • 4
    ntpq -p pool.ntp.org times out from two of my machines, while there is no such problem with ntpdate -q pool.ntp.org. As said by GnP, ntpq -p does not do what the user expects. This incorrect answer should probably be removed. Moreover ntpq cannot be installed under Debian without the associated ntp daemon! – vinc17 Nov 16 '16 at 13:05
24

You can use ntpdate to query a time server

ntpdate -q ntp.ubuntu.com

9

Actually, the command ntpq -c "rv 0 clock" ntp.ubuntu.com will return the time of the server in standard format : this is the result from ca.pool.ntp.org :

clock=d1b5aa9c.b8f9697a  Wed, Jun 29 2011  9:43:56.722

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.