CentOS Linux install and configure NTP to synchronize the system clock

Tuesday, November 18th, 2008 at 1:43 pm by Jiltin
Filed under: Unix Scripts 

You can easily install NTP (Network Time Protocol, a means of transmitting time signals over a computer network) using yum command under Redhat or CentOS/Fedora core Linux.

Login as the root user

Type the following command to install ntp

# yum install ntp

Turn on service

# chkconfig ntpd on

Synchronize the system clock with 0.pool.ntp.org server:

# ntpdate pool.ntp.org

Start the NTP:

# /etc/init.d/ntpd start

Note: If you are using VPS (anything other than dedicated server), you will see this issue repeatedly.In such case, it is better to use ntpupdate with crontab utility instead of nptd service - which may fail to work sometimes. I am writing as many users are having the same issue.

Here is how to implement:

Stop the ntpd processes

# chkconfig ntpd off
# /etc/init.d/ntpd stop

Create a shell script like this
>vi synctime

#!/bin/bash
/usr/sbin/ntpdate ntp.xs4all.nl

Add an entry in cron job
>crontab -e

#min hour day_of_month month day_of_week  user   command
*/05 * * * * /home/work/scripts/crons/synctime > /dev/null 2>&1

It runs every five minutes and you are done!

Comments