1

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.

8 Answers 8

15

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.

3

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

3

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.

1
  • +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.
    – sclarson
    Nov 5, 2009 at 22:58
2

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.

1

You would need the network time protocol deamon link

0

Also, you might try adjtime

0

I`m using exactly this crontab entry.

*/10    *       *       *       *       root    /usr/sbin/ntpdate time.fu-berlin.de > /dev/null 2>&1

time.fu-berlin.de is a server in germany, you can use it also but I suggest using a timeserver nerer to you.

0

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 pool.ntp.org.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .