How to automatically sync date and time on *nix server

Here's how we do it on RHEL:

Logged in as root:

* Create file at /etc/cron.hourly/clockset
* with these two lines only:

rdate -s time-a.nist.gov > /dev/null
hwclock --systohc > /dev/null

* chmod 700 /etc/cron.hourly/clockset

OR
make a crontab entry:
0 6 * * * /etc/cron.hourly/clockset

open firewall ports:
rdate is for port 37.
NTP is for port 123.

source: http://www.directadmin.com/forum/showthread.php?s=&threadid=7484&highlight=sync+time

source of time servers: http://tf.nist.gov/service/time-servers.html

Tags: Server how-to