Trying to configure my Ubuntu server to sync with pool.ntp.org. Following this guide https://help.ubuntu.com/community/UbuntuTime.

I've configured my ntp.conf as following

cat /etc/ntp.conf
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# You do need to talk to an NTP server or two (or three).
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict mask notrust

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth

Then I updated the system to far far away

date -s "2 OCT 2006 18:00:00"

And tried to restart ntpd and the time is still 2006.

ntpq --peers; date
     remote           refid      st t when poll reach   delay   offset  jitter
 dev1-c.sje007.i       2 b   48   64  177   80.623  1205991 1100914
 ox.eicat.ca    2 b   18   64  377   24.743  1205991 1019249
 ntp1.Housing.Be  3 b   62   64  177   94.714   -5.160 6962796
 ns1.your-site.c         3 b   26   64  177   10.913   -9.521 6962796
Mon Oct  2 18:02:29 UTC 2006

Why doesn't ntp behave?


Above a certain difference between local time and pool time, ntp will "slew" the update, i.e. perform little changes all the time. This is so that your system behaviour doesn't completely jump out of the blocks. Here is an extract from the man page:

 -x     Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
              This  option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.  Note: Since the slew rate of
              typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.  Thus, an adjustment as
              much  as 600 s will take almost 14 days to complete.  This option can be used with the -g and -q options.  Note: The kernel time discipline
              is disabled with this option.

With your current time difference it will take you a long time to catch up. I suggest you do a manual change to smaller difference and then observe whether this is working.

  • I should note that it took ntpd several minutes to get the correct time but it dose work, even with such huge variance. Thanks. – Maxim Veksler Jul 29 '10 at 16:49
  • It seems like you haven't read the bit of the man page that you quoted. ntp changes the time progressively if it is under the threshold (usually of less than 1s). It jumps the time if it is over the threshold. If it is over a 'sanity threshold', by default 1000s, it refuses to change it at all. I can't explain the OP's experience but clearly if it corrects by 4 years in 'several minutes' this is not the result of slewing. – jwg May 7 '15 at 11:31

Maybe ntpd adjusts time slow or there are some errores, look for in /var/log/daemon.log or /var/log/syslog (grep -i ntpd /var/log/daemon.log).

A quickly solution is add a cron job ntpdate 0.pool.ntp.org

  • I don't think that I'd put that in a cron job. Most likely the best place to initially synchronize time is in the startup. Most of the startup ntp scripts tries to first sych to a specified (configurable) time server and once that is done then startup ntp. Seems to work well with the 100s of systems that I personally administer. – mdpc Jul 29 '10 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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