SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / server / Questions / 220827
Accepted
John Bachir
John Bachir
Asked: 2011-01-11 12:29:44 +0800 CST2011-01-11 12:29:44 +0800 CST 2011-01-11 12:29:44 +0800 CST

How can I compare an ntp server's time to my server's time?

  • 772

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?

time ntp ntpd
  • 4 4 Answers
  • 82734 Views

4 Answers

  • Voted
  1. user9517
    2011-01-11T12:33:38+08:002011-01-11T12:33:38+08:00

    You can use ntpdate to query a time server

    ntpdate -q ntp.ubuntu.com

    • 37
  2. Best Answer
    jscott
    2011-01-11T12:32:43+08:002011-01-11T12:32:43+08:00

    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.

    • 19
  3. Ion
    2011-06-30T05:48:22+08:002011-06-30T05:48:22+08:00

    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
    
    • 13
  4. pavon
    2021-10-13T14:09:49+08:002021-10-13T14:09:49+08:00

    There are a few different options for querying an ntp server now that ntpdate is deprecated. Which is preferred is often simply a matter of which is already installed (or easy to install) on your OS:

    sntp

    sntp is a tool from the ntp project, and is their recommended tool for querying remote servers:

    $ sntp -K/dev/null ntp.ubuntu.com
    2021-10-12 16:01:48.425034 (+0700) -0.175372 +/- 0.128998 secs
    

    The -K/dev/null is optional, and disables persisting information about the requests to a file. Normal users typically won't have access to this file, so without that option it will print some errors but will otherwise work.

    chronyd

    chronyd is an alternative ntp implementation and the default time server in recent RHEL and Ubuntu distributions.

    $ chronyd -Q "server ntp.ubunutu.com iburst"
    2021-10-27T21:55:49Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
    2021-10-27T21:55:49Z Disabled control of system clock
    2021-10-27T21:55:53Z System clock wrong by -0.233053 seconds (ignored)
    2021-10-27T21:55:53Z chronyd exiting
    

    The -Q tells it to query the server and print results without setting the time (capital is important - lowercase will set the time!). By default it will query the servers configured in it's config file, but you can also give a config line as done above. server is used to specify a single NTP server to query, but pool and refclock could also be used. iburst configures it get an initial result more quickly.

    • 1

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    Check if port is open or closed on a Linux server?

    • 7 Answers
  • Marko Smith

    How to automate SSH login with password?

    • 10 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Resolve host name from IP address

    • 8 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    Smudge Our security auditor is an idiot. How do I give him the information he wants? 2011-07-23 14:44:34 +0800 CST
  • Martin Hope
    kernel Can scp copy directories recursively? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh returns "Bad owner or permissions on ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil How to automate SSH login with password? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin How do I deal with a compromised server? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve