8

My ubuntu 11.10 server has been sitting there quite happily for the last 3 - 4 months, then suddenly the time started going out of sync by one hour. I'm not sure why, nothing has changed re the configuration of the server, i read it can be down to system resource useage.

Anyway to counteract this Ive seen a lot of people recommend installing NTP and the NTP daemon (ntpd) so that the time will be synced automatically. i have installed NTPD and it seems to work for a day, then suddenly stops working.

after around a day when i do

ntpq -q

to list the peers connected, i get the error

ntpq: read: Connection refused

if i then try and restart the service

sudo service ntp restart

i get the following message

* Stopping NTP server ntpd                                                  
start-stop-daemon: warning: failed to kill 26915: No such process                                                                      
* Starting NTP server ntpd 

once i have done this within about 5 mins the time is synced again. If i restart the service again i do not get the above message i just get

 * Stopping NTP server ntpd                                             
 * Starting NTP server ntpd 

and if i try ntpq -p again i get

         remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 noc.be.it2go.eu 193.190.230.66   2 u   43   64    3   10.819  -353184   0.183
 panoramix.linoc 193.67.79.202    2 u   41   64    3   24.647  -353186   0.178
 nsb.lds.net.ua  160.45.10.8      2 u   39   64    3   68.545  -353186   0.001
 europium.canoni 193.79.237.14    2 u   38   64    3    1.222  -353186   0.096

its almost like restarting the service kicks it in to action, yet around a day later i will have to do the same thing all over again as the time will have stopped syncing.

here is what is in the logfile

13 Feb 11:18:38 ntpd[27108]: ntpd exiting on signal 15
14 Feb 11:44:30 ntpd[1872]: ntpd exiting on signal 15
15 Feb 10:16:25 ntpd[26869]: ntpd exiting on signal 15
16 Feb 05:26:41 ntpd[26915]: 158.37.91.134 interface xxx.xxx.xxx.xxx -> xxx.xxx.xxx.xxx
16 Feb 05:51:41 ntpd[26915]: 158.37.91.134 interface xxx.xxx.xxx.xxx -> xxx.xxx.xxx.xxx
16 Feb 10:14:30 ntpd[23793]: ntpd exiting on signal 15

in the log file above, at 13 Feb 11:18:38 the following is what appears in /var/log/syslog

Feb 13 11:18:40 serverx ntpd[29251]: ntpd [email protected] Fri Jun 17 06:06:35 UTC 2011 (1)
Feb 13 11:18:40 serverx ntpd[29252]: proto: precision = 0.118 usec
Feb 13 11:18:40 serverx ntpd[29252]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
Feb 13 11:18:40 serverx ntpd[29252]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen and drop on 1 v6wildcard :: UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 2 lo 127.0.0.1 UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 3 eth0 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 4 eth0:1 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 5 eth0:2 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 6 eth0:3 xx.xxx.xxx.xxxUDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 7 eth0:4 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 8 eth0:5 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 9 eth0:6 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 10 eth0:7 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 11 eth0:8 xx.xxx.xxx.xxx UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 12 eth0 fe80::250:56ff:fea1:41 UDP 123
Feb 13 11:18:40 serverx ntpd[29252]: Listen normally on 13 lo ::1 UDP 123

xxx.xxx.xxx.xxx = ip address

any ideas why this is happening?

8
  • 1
    What does the log say ?
    – adaptr
    Feb 16, 2012 at 9:25
  • Hi im not sure where it logs too? ive not set a logfile in my ntpd.conf Feb 16, 2012 at 9:57
  • Just add logfile /var/log/ntp.log to ntp.conf and restart ntpd.
    – adaptr
    Feb 16, 2012 at 10:57
  • it turns out i did have logging turned on. i have added the logfile contents for the last few days to the original post Feb 16, 2012 at 12:52
  • 1
    Very same issue here, any idea?
    – eskatos
    Jul 9, 2015 at 14:24

1 Answer 1

4

I suspect your clock is too far out for ntpd to be able to drift it back to the correct time. NTP only works if the clock is within +/- 5 mins of the correct time.

Start it with the -g flag to force an ntpdate-style one-off correction. I'm not very familiar with Ubuntu but I suspect there is a defaults/config file for ntpd in /etc somewhere where you can add this flag.

5
  • 1
    but if it was too far out why would it sync to the correct time when i manually stop and start the service? Feb 16, 2012 at 15:25
  • I wasn't quite sure based on your question whether it was actually syncing before (as the offset in your ntpq output was very far off). I would still recommend you start ntpd with -g and then see if it continues to die. Feb 16, 2012 at 15:37
  • hey when i look at the process list it looks like is already started with the -g flag: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 109:116 Feb 17, 2012 at 8:53
  • Seems like this did it. I fixed the 2 hours time drift and up until now, no signal 15 log found.
    – 3bdalla
    Apr 1, 2018 at 7:40
  • @MichaelBarrett Some "ntp" services actually are two-step: First sync the time quick and dirty, and then run ntpd. Maybe that's why the initial run fixes the offset.
    – U. Windl
    Feb 9, 2022 at 9:21

You must log in to answer this question.

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