Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I tell if my Debian system is keeping the system time accurate by getting NTP updates? Basically I want to turn this on if it is currently off, but I don't know if it is on or off.

share|improve this question
add comment

3 Answers 3

up vote 6 down vote accepted

Running

ps ax | grep ntpd

and checking that the output contains something like

6497   ?     Ss    0:04    /usr/sbin/ntpd ...

will confirm that ntpd is running. If it's not running then you can start it with

/etc/init.d/ntp start

If you get an error message No such file or directory then you will have to install the ntp package

sudo apt-get install ntp

Once you have ntpd running you can talk to it with the ntpq command.

ntpq -p 
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*time.nist.gov   .ACTS.           1 u  753 1024  377  139.432   -0.562   2.199
+sip.dicode.nl   193.190.230.66   2 u  733 1024  163   33.197    0.297   0.132
+194.109.64.200  192.87.106.2     2 u  779 1024  377   35.214   -0.323   0.027
 LOCAL(0)        .LOCL.          10 l    3   64  377    0.000    0.000   0.001

Which shows (offset) that my system is <1 second out of sync - I can live with that.

share|improve this answer
add comment

If you have peer statistics enabled in your /etc/ntp.conf then you have statistics in /var/log/ntpstats/peerstats. (Directory and file name will be specified in ntp.conf). You can scan it to see how well you are tracking your servers. The command grep -v 127.127.1.0 /var/log/ntpstats/peerstats will output all the lines except those for your local clock. The first floating point number is the offset in seconds. The closer it is to zero the better. There should be a mix of positive and negative values. Use zgrep to look a historical data in the rotated logs with a .gz extension.

To see what the values are use ntpq -p as Iain suggested.

If you run Munin to monitor your system it can track you ntp statistcs for you. I believe the offset it records is the value relative to the currently synchronization source. That is the one on the line starting with an asterisk (*) in the ntpq -p output. Munin can be configured to notify your offset is too large. My warning lines are as follows (times in milliseconds):

    ntp_offset.delay.warning    40
    ntp_offset.offset.warning   -15:15
share|improve this answer
add comment

A cheap and dirty way to check the local clock vs another machine is this shell command sequence:

date; telnet somehost 13; date

"somehost" has to run the RFC 867 "daytime" protocol, and that's not so common anymore. inetd can provide "daytime" by itself, and some hosts still have "daytime" enabled.

You can at get an independent check on the local clock, no use of NTP necessary.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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