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

  1. Login as the root user

    Type the following command to install ntp

    # yum install ntp

  2. Turn on service

    # chkconfig ntpd on

  3. Synchronize the system clock with server:

    # ntpdate

  4. 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

  1. Stop the ntpd processes

    # chkconfig ntpd off
    # /etc/init.d/ntpd stop
  2. Create a shell script like this

    >vi synctime
  3. 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
  4. It runs every ten minutes and you are done!