Ntpdate
From Wsms
Note: This page should be titled ntpdate (all lowercase). It is Ntpdate due to a technical limitation of Mediawiki.
Contents |
ntpdate
ntpdate synchronizes your system clock to a a server.
basic usage
root@harrison:~# ntpdate pool.ntp.org 5 Oct 15:28:55 ntpdate[7321]: adjust time server 64.72.116.45 offset -0.308659 sec
ntpdate versus ntpd
On most systems you can install ntpd and never bother with ntpdate. ntpd runs in the background in is considered more accurate than ntpdate. You only need ntpdate if your clock is way out of sync.
If you are running ntpd, you need to stop it before running ntpdate. This is one way to do it on CentOS/RedHat/Fedora:
[root@centos ~]# service ntpd stop Shutting down ntpd: [ OK ] [root@centos ~]# ntpdate 0.rhel.pool.ntp.org 4 Mar 07:42:36 ntpdate[2631]: step time server 64.202.112.75 offset 28458.759904 sec [root@centos ~]# service ntpd start Starting ntpd: [ OK ]
vmware
If you run vmware on a system where the clock speed changes due to cpu frequency scaling, the clock on the virtual machine will be highly inaccurate. I found that ntpd fails in this situation. One solution is to set up a cron job that regularly runs ntpdate.
The cron script to set the time every minute from a host on your LAN might look like this:
# min hour dom mon dow * * * * * /usr/sbin/ntpdate 192.168.2.12 >> /var/log/ntpdate.log 2>&1
This solution actually resets the time as much as three times every minute. The VM's clock runs fast and the cron job sets the time back several seconds, when the minute turns again, the cronjob runs again, setting the clock back again, and so on. This is fine if the time server is on the local network, but probably not acceptible if you are using a public time server on the internet.
VMWare tools is supposed to fix the time drift problem, but it didn't work for me when I tried it.--Ggeller 09:11, 4 March 2008 (PST)
see also
Linux_commands
20061120
20061215
Ntpd
Nohup
Ntp
CPU_frequency_selection
