How do I configure an NTP (Network Time Protocol) client to keep time on the servers synced?
The Network Time Protocol (NTP) is used to synchronize a computer's time with another reference time source. Under CentOS / RHEL you can use NTP or OpenNTPD server software. Both package provide client and server software programs for time synchronization. Steps below will help to perform NTP installation and configuration.
The ntp package contains utilities and daemons that will synchronize your computer's time to Coordinated Universal Time (UTC) via the NTP protocol and NTP servers. The ntp package includes ntpdate (a program for retrieving the date and time from remote machines via a network) and ntpd (a daemon which continuously adjusts system time).
Install the ntp package:
# yum install ntp
To configure the client open /etc/ntp.conf file, enter:
# vi /etc/ntp.conf
Make sure the following line exists:
Where ntp.server.com is the hostname or IP address of the site NTP server. If your ntp server is located at 192.168.1.5, enter
server 192.168.1.5. You can also use public ntp server located at ntp.org.
Enable service for autostart and launch it:
# chkconfig ntpd on # service ntpd start
You can also run ntpd using cron:
# echo '30 * * * * root /usr/sbin/ntpd -q -u ntp:ntp' > /etc/cron.d/ntpd
The above instructs crond to run ntpd and after setting the clock just exit, and the -u option instructs it to run as the ntp user.