Setting Up NTP Time Synchronization in CentOS

By | January 29, 2010

If you need to have valid date and time on your server, you need to synchronize it with a time server as well. In order to do this in Linux (especially in CentOS),  we will follow my short howto.

1. Ensure you’ve got ntp installed. Run rpm -qa | grep ntp to find out if it already exists on your system and yum install ntp if it is not present.

2. Run ntpdate. On CentOS, you will probably get this error:

[root@server ~]# ntpdate
29 Jan 09:52:54 ntpdate[8463]: no servers can be used, exiting

This means you have to include a server into your request, just like shown below.

[root@server ~]# ntpdate 0.pool.ntp.org
29 Jan 10:08:07 ntpdate[8853]: step time server 213.198.55.2 offset 676.605025 sec

This means my server had a 10-minute time diffrence with the time server. After this command my time has been adjusted.

3. Add time synchronization to your crontab and run it as often as you need.

30 * * * * /usr/sbin/ntpdate -s 0.pool.ntp.org

Will sync your clock every hour; I think is enough to perform synchronization weekly.  Let’s do it.

30 10 5 * * /usr/sbin/ntpdate -s 0.pool.ntp.org

This simple guide will keep your clock synchronized. Have fun!

3 thoughts on “Setting Up NTP Time Synchronization in CentOS

    1. admin Post author

      I think that this method is easier even for newbies. :)

  1. Pingback: Liberty Reserve Automation: 200Authentification Error | LAMPdocs: Linux, Apache, MySQL, PHP

Comments are closed.