22

In order to keep the time accurate on a Ubuntu system one can either:

  • Run the ntpd (network time protocol daemon) which will run all the time and continuously adjust the system time when clocks drift. or alternatively:
  • Call ntpdate periodically (e.g. from cron)

Questions:

  • What are the pros and cons of each of these two methods?
  • Which different scenarios call for picking one over the other?
26

ntpdate is deprecated as of September 2012; apparently ntpd now has the ability to do one-time updates if needed, and ntpdate is based on "long-neglected" ntpd code. (News to me, since my system has ntpdate but not ntpd! I'll be fixing that presently; thanks for asking this question.)

As for the difference between continuous versus periodic updates, I think the trade-offs there are what you would expect; continuous adjustments maintain better accuracy over time, which can be important for databases and MailDir (see same link). But of course this would require slightly more network traffic (presumably negligible for exchanging simple timestamps) as well as an always-online network connection, slight consumption of RAM and CPU, etc. But all these downsides are tiny in a modern computing environment; overall I doubt there are good reasons to substitute cron for ntpd.

1
  • 2
    Thanks so much for the answer. I had no idea that ntpdate has been deprecated. It has been working well for me for years. – arielf May 21 '13 at 14:32
5

As far as I understand the Linux System Administrators Guides NTP chapter, "continuous updates" doesn't mean that ntpd constantly queries its servers (like once a second), but that the time corrections do not introduce discontinuities.

Instead of just setting the correct time, ntpd will run your computers clock slightly slower or faster until it reaches the correct time (assuming the error is not too big). This avoids problems with software running havoc because of gaps in time or negative durations -- most programmers won't expect a process to finish before it started and thereby giving a negative duration...

Furthermore, the manual states that ntpd also learns and compensates the drift of your computers clock (at least the constant part).

The Network Time Protocol Project has a nice FAQ (http://www.ntp.org/ntpfaq/) explaining NTP and how it keeps the time.

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.