I have several servers in Amazon EC2. Having noticed time difference on the instances I have installed ntp. I see /etc/cron.daily/ntp Cron job was added.

Still I notice that, for some reason, the time drifts quite fast.

I am planning to make a symlink in /etc/cron.hourly to /etc/cron.daily/ntp.

Will this help?

  • 3
    Why not run the NTP daemon? (Yes, it's "ok" to run NTP hourly.) – Aaron Copley Dec 29 '15 at 15:19
  • @AaronCopley ntp package is the NTP daemon in Ubuntu, afaik – warvariuc Dec 29 '15 at 15:31
  • 1
    Ah, I see. /etc/cron.daily/ntp doesn't do what I thought it does. It doesn't force time synchronization, it just gathers some stats. – warvariuc Dec 29 '15 at 15:34
  • If you run ntpq -p you will probably find your clocks are already synched by ntpd; the daemon runs automatically when the package is installed. – Michael - sqlbot Dec 29 '15 at 15:57
  • Got it. I am more familiar with the Red Hat side of things where there is a daemon package and an NTP client package each available. Still, you shouldn't have drift if the daemon is running and configured. – Aaron Copley Dec 29 '15 at 16:34

I know you've already figured this out, but I wanted to add some information for anyone who might stumble across this. It seems that you were confusing ntpd (the ntp package) with ntpdate. ntpd is a daemon that continuously keeps time in sync. It does this in a very involved, very safe, and fairly complex manner, and typically involves multiple timeservers. You can see the status of NTP's time synchronization, and the servers it is syncing with, by running:

ntpq -p

It's output is explained here.

The cronjob /etc/cron.daily/ntp is for the sole purpose of processing daily stats from ntpd's statsdir. As far as whether this can be run multiple times per day, I'm sure there's a way, but you probably don't need to, and it might cause problems :)

What I believe you were originally thinking of was the manual NTP command ntpdate. ntpdate <timeserver> simply synchronizes time with a remote timeserver a single time. And, sure, you could run this command in cron as frequently as you want. However, ntpdate synchronization is not only less performant, but it results in considerably-less-synchronized time. It's a good way to quickly synchronize time for a server not running ntpd, or if the clock is very badly out of sync, for an initial synchronization (ntpd will only change the clock by so much at one time). You can't run ntpdate while ntpd is running, though.

ntpdate -b <timeserver> is actually run by many Linux distributions at boot time, before ntpd starts.

|improve this answer|||||
  1. Ensure that you have installed the ntp package (ntp daemon and utilities).

  2. Ensure that you have configured the ntp daemon. (RHEL /etc/ntp.conf)

  3. Ensure that the service is working correctly. (RHEL service ntpd status, date)

These steps are all distribution specific, but a simple search will find instructions on how to set this up.


 # yum install ntp
 # vim /etc/ntp.conf
 make sure you have valid, available time servers listed
 # service ntpd restart
|improve this answer|||||

ntpdate is depracated, and you can use ntpd -gq to update time forcefully rather than on a schedule.

This works for VMs that don't have guest os tools installed, and experience periodic clock drift, although there may be a better way.

|improve this answer|||||
  • ntpdate is only deprecated in rolling release and short cycle distributions. Most servers use long term support releases (or should, by best practice). ntpd -gq tells a RHEL system to allow the first adjustment to be big, and to set the time and quit. Far better to install and correctly configure the NTP client. – Xalorous Feb 23 '17 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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