Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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

  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
share|improve this answer
In fact, ntp-date is just a stripped-down version of NTPD, used for one-shot sync. – jmendeth Apr 1 '13 at 17:10
Thanks, but on one of the servers this didn't work, this is the tail result:Apr 1 21:46:37 v ntpd[3761]: Listening on interface eth1, Enabled Apr 1 21:46:37 v ntpd[3761]: kernel time sync status 0040 Apr 1 21:46:37 v ntpd[3761]: getaddrinfo: "::1" invalid host address, ignored Apr 1 21:46:37 v kernel: megasr[ahci]: unable to retreive proper sense data Apr 1 21:47:56 v kernel: ip_conntrack: table full, dropping packet. Apr 1 21:47:58 v kernel: megasr[ahci]: unable to retreive proper sense data Apr 1 21:48:30 v last message repeated 105 times – Andrew Apr 2 '13 at 0:55
@Andrew, is was the 1st of April, nevermind – poige Apr 2 '13 at 5:34
The only caution I'd add is that I consider ntpd's access restriction behavior pretty obtuse.… has flow chart documentation for locking it down. Nice if you have a firewall, a potential mandate if you don't. – astrostl Apr 2 '13 at 19:51

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.