7

I have a few dedicated servers and for some reason they are totally unable to mantain the time properly synchronized, every few days they start having differences of minutes in the clock. So I have to manually open Putty, connect, login, and run the ntpdate -u 0.ar.pool.ntp.org command on each of them.

Since there's no way I can do this every day because I'm quite busy, the question is exactly how can I create some kind of cron that auto-runs this command every day on each server. I have full root access to all servers, they have CentOs and DirectAdmin. Thanks.-

andreszs
  • 709

2 Answers2

16

No need to use cron for this task. Much better to install and configure ntpd (special daemon for continuous time sync).

  1. sudo yum install ntp
  2. sudo chkconfig ntpd on
  3. sudo nano /etc/ntp.conf
  4. you are from Argentina, right? comment/remove all the default CentOS ntp servers, you can add your own time-servers for Argentina, for example

    server 0.ar.pool.ntp.org
    server 1.south-america.pool.ntp.org
    server 0.south-america.pool.ntp.org
    
  5. After you are done with the configuration, just start the ntp service: sudo service ntpd start

  6. To check if the NTP service is synchronizing:

    sudo ntpq -pn
    sudo tail -f /var/log/messages
    
cadmi
  • 7,787
7

Instead of using ntpdate which resets time hardly at once, consider using NTP daemon (ntp packet). It slows down or fastens system clock to match NTP-server.

gevial
  • 1,434