1

My SES setup was running fine for the last 6 months without any issues. All of a sudden it stopped working yesterday and I'm gettinng the infamous time sync error.

Naturally I assumed ntpd had stopped, but to my surprise when I checked the process tree, I noticed that it was running.

 ~  ps auwx | grep ntpd                                 
ntp      18223  0.0  0.0  33600  2132 ?        Ss   07:05   0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 106:112
ubuntu   19127  0.0  0.0   8144   668 pts/5    S+   07:19   0:00 grep ntpd

Then I tried ntpdate which said

2 Sep 07:16:09 ntpdate[18966]: no servers can be used, exiting

I checked the /etc/ntp.conf file which had the default ubuntu servers listed by default.

# /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

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com

# 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 127.0.0.1
restrict ::1

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


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

# 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
#broadcastclient

I couldn't spot the issue here. Then I tried to check the status of NTP server and found no issues there.

/etc/init.d/ntp status                             
 * NTP server is running

I also tried adding a NTP server manually to see if it worked, but that didn't help either

 sudo ntpdate ntp.ubuntu.com                         
 2 Sep 07:20:08 ntpdate[19203]: the NTP socket is in use, exiting

I really don't understand what the issue is here. Why is ntpd not working when it's running in the background?

Any help would be appreciated. Thanks.

skmvasu
  • 123
  • 1
  • 6
  • Does `ntpstat` will give you more of a status. You can use `ntpq` to interact with the running ntp server as well. – HBruijn Sep 02 '14 at 08:11
  • Can you do `sudo service ntp restart ; sleep 120 ; ntpq -pcrv` and past the output? And if you really want to make it easy always include relevant syslog `grep ntpd /var/log/syslog` – dfc Sep 29 '14 at 02:45
  • And can you also paste `ntpq --version` and `diff -u /etc/ntp.conf /etc/ntp.conf.dhcp` – dfc Sep 29 '14 at 08:11

2 Answers2

0

You need to stop ntpd before running ntpdate.

sudo service ntp stop
sudo ntpdate 0.ubuntu.pool.ntp.org
sudo service ntp start
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
0

On ubuntu you should use

ntpd -q

instead of ntpdate if you have installed ntpd

Manpage:

-q     Exit the ntpd just after the first time the clock is set.  This behavior mimics that of the ntpdate program, which is to be retired.
       The -g and -x options can be used with this option.  Note: The kernel time discipline is disabled with this option.
Christopher Perrin
  • 4,741
  • 17
  • 32
  • 1
    "You should use `ntpd -q`" That is terrible advice. People should use `ntpd` or chrony unless they have good reason to reject kernel time discipline. OP had a functioning ntpd setup up until recently. Why would you reccomend an "option" that is a significant reduction in timekeeping aaccuracy/precision? – dfc Sep 29 '14 at 02:43
  • He had a hiccup probably and wants to get to the exact time quickly. The shown command does just that. – Christopher Perrin Sep 29 '14 at 05:08
  • 1
    But it doesn't. How do you know his clock is not off by more than the panic threshold? If it is `-q` wont fix things. He did not need -q for the last six months with ntpd functiong acceptably. Why did you decide that he does not need kernel time discipline provided by ntpd? The big problem is that there is no indication of the exact problem. Without a peers billboard and relevant syslog messages everything is just a guess. – dfc Sep 29 '14 at 08:04