Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I run Debian on several systems, and their times do not seem to stay in sync. I can run ntpdate manually, but I thought that I should have an ntpd running that would automate that.

I did check with apt and apt-cache but don't find any ntpd (or associated ntpq), not any such names in my system (locate...), but ntp-doc does still describe them.

Looking around I see that there is an ntpdate-debian command, and it uses /etc/default/ntpdate for servers (instead of the standard /etc/ntp.conf), but even thought that file is there and has "yes" indicated to use ntp.conf, it fails with "no servers can be used", although ntpdate works fine. Is this just a layer over ntpdate, any reason to use it instead?

So, why are they missing, do I need them, how do I automate time updates?

Associated, two of my machines are virtualized on a MSoft VM, how is it that their clocks drift, and both to different values? (The underlying Windows machine clock seems stable). I see a few old notes about time & ntp problems on VMware, didn't find anything either current or relating to MSoft VMs. Anything I did see says just to use ntpd, but as above, ...?!

share|improve this question

migrated from stackoverflow.com Jan 27 '12 at 16:08

This question came from our site for professional and enthusiast programmers.

    
For the Hyper-V VMs you need to enable integration services. I believe there's an apt package or something similar. I would expect ntpd to be part of the base OS, but maybe I'm used to more advanced *nix clones. –  Chris S Jan 27 '12 at 16:16
    
Thanks - good pointer. But from the MSoft site they seem to only support SUSE & Red Hat. –  guthrie Jan 28 '12 at 20:27
    
It's also odd that two identical (cloned) Debian VMs on the same system have very different clock drifts. One was .4 secs off after 2 days, the other 49 seconds. –  guthrie Jan 29 '12 at 14:12
    
If ntp is installed running, can you post the output of ntpq -p? –  Zoredache Feb 1 '12 at 1:07
    
(See below) - The ntpq output is hard to format in a comment, but I think the useful part is the (delay,offset,jitter) results - (.189,2.9,.1), 3.6,2.9,.1), –  guthrie Feb 1 '12 at 13:23

4 Answers 4

The package you are looking for is ntp, which provides daemon and utilities for time synchronization.

share|improve this answer
    
As noted above, I already installed ntp, and also ntpdate-debian, and ntp-doc. The lack of automatic synchronization ntpd-style lead to the above question. –  guthrie Jan 28 '12 at 5:12
    
Sorry guthrie, it wasn't clear from your question that ntp was installed. If so, maybe there's some kind of configuration glitch in /etc/ntp.conf? Can you post it? ntp has worked out of the box on all my servers. –  adc Jan 29 '12 at 12:59
    
Thanks. I think the ntp.conf is ok, since ntpdate works fine manually. There is no ntp.conf file but since I don't seem to have ntpd (which uses it), I don't think the file is used anyway. I wanted some automation which I think ntpd is supposed to provide. (I do have to give ntpdate the server argument, which I would have thought would come from the .conf file.) –  guthrie Jan 29 '12 at 14:15

Seems to have been some install problem, I reinstalled ntp and it seems to now be corrected and ok. I don't know how it went wrong before, since ntpdate was there, but not the others.

share|improve this answer

If you have a stock ntp.conf from the you may want to look adding the tinker panic 0 option to your ntp.conf. This will permit it to ignore clock jumps that wouldn't normally happen on physical hardware.

If your hypervisor is trying to do time-sync then you should get rid of ntp. Only one service should be trying to manage time within the VM. If you have an agent for your hypervisor installed, and NTP running at the same time, then badness will result.

Since you have the ntp daemon installed, make sure it is started, and then verify that it is actually running by using the ntpq -p command. This command will report which peer was selected, and some stats about NTP.

#ntpq -p -n
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+192.168.78.130   172.16.16.34    2 u   81  128  377    0.189    2.935   0.164
*172.23.206.10   172.16.16.34    2 u   72  128  377    3.648    2.902   0.109
+216.129.110.22  69.36.224.15     2 u   10  128  377   92.224  -23.697   0.704
share|improve this answer
    
I am not sure how to tell if I have the situation you describe with a hypervisor agent for time sync. The ntpq output is (Hard to format in a comment!): alpha:/home/net# ntpq -p -n remote refid st t when poll reach delay offset jitter +71.6.217.53 131.107.13.100 2 u 13 256 377 77.277 -4.492 4.622 *108.71.253.20 .GPS. 1 u 1 256 373 104.012 -14.622 7.761 +74.118.152.85 69.36.224.15 2 u 147 256 277 69.100 -10.436 5.534 -97.107.134.28 128.4.40.12 3 u 223 256 377 38.207 -7.521 5.509 –  guthrie Feb 1 '12 at 13:16
    
Fighting with the comment editor! - The ntpq output is hard to format in a comment, but I think the useful part is the (delay,offset,jitter) results - (.189,2.9,.1), 3.6,2.9,.1), –  guthrie Feb 1 '12 at 13:22
    
You could have just updated your question with the new information. –  Zoredache Feb 1 '12 at 17:33
    
Thanks - protocol now learned! –  guthrie Feb 2 '12 at 2:07

Can you add a cron job for it? This is the script I use on ubuntu-server 12.04:

echo '#!/bin/bash
ntpdate ntp.ubuntu.com
' > /etc/cron.daily/ntpdate
chmod +x /etc/cron.daily/ntpdate

This is the same approach recommended by racksapce.

share|improve this answer
    
bad idea, creates gaps in the time continuum –  asdmin Jun 26 '12 at 12:48
    
Can you share more details? –  JoeCoder Jun 28 '12 at 21:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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