Install NTPD Daemon to enable NTP in Linux
To enable NTP synchronisation over NTP (Network Time Protocol), all you need is to install NTP using yum command.
Main linux systems that understand following tutorial
- CentOS
- RedHat
- Fedora
Easy steps to install and configure NTP on CentOS
-
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
Configure crontab to use NTP on Linux Machine
Note: If you are using VPS (anything other than dedicated server), you will see following issue repeatedly. In such case, it is better to use ntpupdate with crontab utility instead of nptd service – which may fail to work sometimes.
Process of configuration
-
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 */10 * * * * /home/work/scripts/crons/synctime > /dev/null 2>&1
-
It runs every ten minutes and you are done!