6

I'm having some strange problem with the clock on my server – it's about 10% faster than normal.

The problem started 2 days ago and I've not done anything special with the server.

I tried to turn of the ntp update by stopping the ntpd daemon.

It looks like the hardware clock is disabled.

→ sudo hwclock --show
select() to /dev/rtc to wait for clock tick timed out
  • Server has not been restarted for 100+ days
  • Linus distro is Debian squeeze/sid
  • ntpd daemon is turned of
  • Server is a VPS, non of the other customers have had any problem
  • I've not changed anything related to the clock in terms of software
  • Running sudo date -s "Sun Feb 5 00:30:15 CET 2012" or sudo ntpdate -b prrr.se, fixes the problem temporarily

I tried to mesure the offset by using ntpdate -b prrr.se. This is the result

After 5 sec

→ sudo ntpdate -b prrr.se
 5 Feb 00:19:54 ntpdate[24137]: step time server 178.78.255.254 offset -1.179405 sec

After 10 sec

→ sudo ntpdate -b prrr.se
 5 Feb 00:20:04 ntpdate[24142]: step time server 178.78.255.254 offset -2.480711 sec

After 20 sec

→ sudo ntpdate -b prrr.se
 5 Feb 00:20:24 ntpdate[24149]: step time server 178.78.255.254 offset -4.680055 sec

Can anyone explain to me why this is happening and what might be the solution?

Linus Oleander
  • 177
  • 1
  • 4
  • 13

3 Answers3

3

Turn ntpd back on. It's job is to figure out how fast the clock is running and apply an appropriate correction.

David Schwartz
  • 31,215
  • 2
  • 53
  • 82
  • But it hasn't been working for over 24h now – using the ntpd daemon. – Linus Oleander Feb 05 '12 at 01:56
  • Your question says the NTP daemon is off. If it's on, then how is it configured? And what does its monitoring say? – David Schwartz Feb 05 '12 at 02:15
  • Yes, I turned it off, just for debugging. Before that it was on for about 400 days. This is my config file: https://gist.github.com/a7c061f77e765216f6cf What did you mean by "monitoring"? – Linus Oleander Feb 05 '12 at 03:17
  • NTPD has sophisticated monitoring that allows you to tell if it's able to community with its peers or servers, which one it has chosen to sync with, whether it actually is in sync, and so on. If you normally run with NTPD on, what's the point of debugging with it off? You should be debugging the configuration you run. – David Schwartz Feb 05 '12 at 04:06
  • @Oleander Depending how your NTP is configured it can either reset or slew the time. If it does the latter it usually has a configuration to stop updates if the clock drifts away longer then particular amount. Secondly depending on virtualization software used you may have sync to host problem. – Karlson Feb 05 '12 at 06:20
  • @David Turning ntpd off was the part of the debugging process. Maybe the daemon was using a non working, off sync time server? – Linus Oleander Feb 05 '12 at 14:09
  • @Oleander Maybe, but with it not running, how can you tell? By shutting NTPD off, you made it much more difficult to debug. – David Schwartz Feb 05 '12 at 15:24
3

Virtual servers have notoriously unreliable clocks, since they don't get reliable ticks from the CPU. They're even worse than the clocks in physical machines. It depends mostly on the load of the hypervisor your VPS is running on, so maybe you're seeing more drift since the load of the physical server has increased.

Simply enable NTPD, and point it to some NTP servers. NTP will figure out how fast your clock drifts, and will slow it down by the right amount. It will periodically monitor and adjust these values, leading to very accurate time. The NTPD daemon takes few resources and is very effective, so I would suggest just enabling it.

Martijn Heemels
  • 7,438
  • 6
  • 39
  • 62
  • +1. Exactly. I virtualize prettym uch all of my infrastructure EXXCEPT.... machine uses to handle real time data feeds. Beacause the closk i RIDICULOUS and when you measure latency in a network etc. - it just starts alawrms every second. It cflucuates like 3-4 seconds per minutee back and forth. – TomTom Feb 05 '12 at 08:21
  • Also see this vmware's KB: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427 – Jure1873 Feb 05 '12 at 10:40
  • This answer still doesn't change the fact that the ntp daemon isn't working. – Linus Oleander Feb 05 '12 at 14:07
  • What do you mean 'not working'? You mentioned it was turned off. What happend when you enable it? – Martijn Heemels Feb 05 '12 at 23:07
1

The ntpdate command is a one-off. You want the ntpd daemon running to make minute adjustments.

# /etc/init.d/ntpd stop
# ntpdate time.nist.gov
# /etc/inid.d/ntpd start
# watch 'ntpq -pn'

Pay attention to the symbols on the left hand side of the output of ntpq. Those will tell you once you have a sync.

dmourati
  • 24,720
  • 2
  • 40
  • 69