Server Administration & Management

How to synchronize time with NTP servers

1. Synchronizing time with NTP(Network Time Protocol) server.

# which ntpdate

2. If its not available type:

# yum install ntp

3. Once ntp is installed synchronize your computer clock with:

# ntpdate 0.us.pool.ntp.org

4. You are not limited to the above server. There are numerous NTP servers around the world. You can find a complete list at ntp.org. Also keep in mind that ntp only affects the system time. The hardware clock on your server will not reflect that. So you want to set it as well so that the correct time is maintained after reboot:

# hwclock –systohc

# ntpd

5. To keep your server clock automatically synchronized you can run the ntpd daemon which is installed as part of the ntp package. Edit the /etc/ntp.conf file to comment out the following lines:

# vi /etc/ntp.conf

#server     # local clock
#fudge stratum 10

6. The above two lines can sometimes prevent ntpd from properly synchronizing your clock. They are already commented out by default on CentOS/RHEL 6. But on 5.x you have to comment them out manually. Finally type the following two commands to start the daemon and make it run automatically at boot up:

# service ntpd start

# chkconfig ntpd on

November 5, 2011 Posted by | NTP, Tips & Tricks, Unix/Linux | , , , | Leave a comment