3

I'm managing some VirtualBox developer environments. The time drifts out of sync when the box is suspended, so I want to use NTP to keep it in sync.

NTP doesn't seem to be doing its job, though - the time does not get updated.

It does work if I do this:

$ service ntp stop
$ ntpdate au.pool.ntp.org
$ service ntp stop

Here is my /etc/ntp.conf:

driftfile /var/lib/ntp/ntp.drift

# Set tinker panic - see http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427
# Makes time sync more aggressively in a VM.
tinker panic 0

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

# Specify one or more NTP servers.
server au.pool.ntp.org

# Specify one or more NTP servers.
server 0.pool.ntp.org

Here's the relevant lines from /var/log/syslog:

Jun 20 18:51:30 vg ntpd[7239]: ntpd [email protected] Tue Jun  5 20:12:08 UTC 2012 (1)
Jun 20 18:51:30 vg ntpd[7240]: proto: precision = 0.191 usec
Jun 20 18:51:30 vg ntpd[7240]: ntp_io: estimated max descriptors: 1024, initial socket boundary: 16
Jun 20 18:51:30 vg ntpd[7240]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen and drop on 1 v6wildcard :: UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 2 lo 127.0.0.1 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 3 eth0 10.0.2.15 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 4 eth1 192.168.33.10 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 5 eth2 192.168.0.156 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 6 eth0 fe80::a00:27ff:fea0:5444 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 7 eth2 fe80::a00:27ff:fe1c:18ae UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 8 eth1 fe80::a00:27ff:fe02:b8f6 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: Listen normally on 9 lo ::1 UDP 123
Jun 20 18:51:30 vg ntpd[7240]: peers refreshed
Jun 20 18:51:30 vg ntpd[7240]: Listening on routing socket on fd #26 for interface updates

In the above logs, the date is a full 14 hours behind.

The three interfaces are a quirk of our dev environment. eth2 is the interface with an IP on the office NAT, providing internet access.

I have NTP 4.2.6, running on Ubuntu 12.04 (Precise).

Why is NTP not updating the time on this machine?

Cera
  • 534
  • 4
  • 8
  • 21
  • Have you tried `ntpdate -b`? – Hauke Laging Jun 21 '13 at 03:00
  • can you try add ntp server address to `/etc/ntp/step-tickers` and then restart the ntp service. I had a simlar issue with vmware host and it works for me. – Raza Jun 21 '13 at 03:40
  • NTP won't even try if the time is too far off. – jordanm Jun 21 '13 at 03:47
  • Have you tried running `ntpdate pool.ntp.org` first without the ntpd daemon running? Next, are you confident the ntpd daemon is running (try running `ntpq -p` for a list of upstream NTP servers and measured delay/jitter/status). Finally double check your virtual host manager isn't also fighting to set the clock also (VMWare is notorious for this). – PP. Jun 21 '13 at 11:20

1 Answers1

2

In general NTP is good at keeping the time in sync but if the time is radically different between 2 systems then it will take NTP a while to get the times between the 2 systems in sync. I usually use ntpdate to get the time in sync first like so:

$ ntpdate -u 0.us.pool.ntp.org

And then start the NTP service afterwards. This adjusts the time in a gross way and then enlists NTP to keep the time in sync afterwards going forward.

slm
  • 363,520
  • 117
  • 767
  • 871
  • 4
    This is what `ticker panic 0` is meant to do, though: "The configuration directive tinker panic 0 instructs NTP not to give up if it sees a large jump in time. This is important for coping with large time drifts and also resuming virtual machines from their suspended state." – Cera Jun 21 '13 at 05:57
  • 1
    @Cerales - thanks for pointing that out, I'd never noticed the tinker option before. I found this thread over on SO that discusses your problem, [specifically this answer](http://stackoverflow.com/a/14634941/33204). Try moving the tinker option to the top of the file and also make sure that you're following the recommendations in that SO Q&A too. The man page for `ntp.conf` also says the same thing about `tinker` options being the first thing in the file. – slm Jun 21 '13 at 12:11