Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server. However, a server's clock is likely to drift considerably between reboots, so it makes sense to correct the time ocassionally. The easiest way to do this is to get cron to run ntpdate every day. With your favourite editor, as root, create a file
ntpdate ntp.ubuntu.comThe file
/etc/cron.daily/ntpdatemust also be executable.
sudo chmod 755 /etc/cron.daily/ntpdate
To set up ntpd:
sudo apt-get install ntp-simple
ntp.ubuntu.comby default. This is OK, but you might want to use several servers to increase accuracy and resilience, and you may want to use time servers that are geographically closer to you. to do this for ntpdate, change the contents of
ntpdate ntp.ubuntu.com pool.ntp.orgAnd for ntpd edit
/etc/ntp.confto include additional server lines:
server ntp.ubuntu.com server pool.ntp.orgYou may notice
pool.ntp.orgin the examples above. This is a really good idea which uses round-robin DNS to return an NTP server from a pool, spreading the load between several different servers. Even better, they have pools for different regions - for instance, if you are in New Zealand, so you could use
pool.ntp.org. Look athttp://www.pool.ntp.org/ for more details.
You can also Google for NTP servers in your region, and add these to your configuration. To test that a server works, just type
sudo ntpdate ntp.server.nameand see what happens.
ref : https://help.ubuntu.com/7.04/server/C/NTP.html