Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

What script or program is needed to keep a unix system date correct? I find that my linux servers are behind a few minutes from actual time.

share|improve this question

migrated from Nov 5 '09 at 21:44

This question came from our site for professional and enthusiast programmers.

Use ntpd.

From manpage:

The ntpd daemon synchronizes the local clock to one or more remote NTP servers, and can also act as an NTP server itself, redistributing the local time.

share|improve this answer

You're looking for ntp. Here's some info for installing and configuring it on Ubuntu.

share|improve this answer

We use ntpdate - which I think is a lot lighter weight than the full ntp.

I have a cron job that runs "ntpdate my.ntp.server > /dev/null" a couple times per day to keep things in sync.

If it is important that your time be adjusted gradually (rather than synched immediately), then ntp would be your better option.

Note that if this is a virtual machine, time drift is a common problem, and there might be some included "tools" that allow you to sync time with the host machine - usually a better option.

share|improve this answer
+1 for the mentioning of how this issue happens more on virtual machines. I've used a service set to do this more regularly but cron obviously works great too. – sparks Nov 5 '09 at 22:58

ntpd, as others have pointed out, is the obvious choice to keep the clock in sync once it's set. However, you'll probably also want "ntpdate" to set it initially from a good network time source, as ntp won't adjust the clock if it's more than a couple minutes out of sync.

Both should be available from the package manager of the Linux distro you're using.

share|improve this answer

You would need the network time protocol deamon link

share|improve this answer

Also, you might try adjtime

share|improve this answer

I`m using exactly this crontab entry.

*/10    *       *       *       *       root    /usr/sbin/ntpdate > /dev/null 2>&1 is a server in germany, you can use it also but I suggest using a timeserver nerer to you.

share|improve this answer

If you are going to use ntp, which recommendation I would second (er, third; well, Nth), you will need a timeserver. If your organization does not have one, you can use

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.