[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Fixing time drift

Posted on 2004-10-20
9
Medium Priority
?
829 Views
Last Modified: 2013-12-06
Our servers info:
Red Hat 9
[foxadm@xxx foxadm]$ uname -a
Linux xxx.xxx.com 2.4.21 #1 SMP Wed Jun 16 15:36:44 EDT 2004 i686 i686 i386 GNU/Linux

One of our servers has been experiancing some serious time drift (about 30 minutes a day). the hardware clock is fine, its the system clock that seems to be drifting.

Ex. /usr/sbin/hwclock --systohc was run less than 24 hours ago:

[foxadm@xxx foxadm]$ date;/usr/sbin/hwclock
Wed Oct 20 12:04:06 EDT 2004
Wed 20 Oct 2004 11:49:49 AM EDT  -0.346284 seconds

I have a cron job running every 10 minutes to sync the system clock, but Im not sure I like this arangement.

I understand ther is a utility (adjtimex) for adjusting the timing in the kernel. Could someone provide some examples of how to use it or does anyone have any other advice on how to fix this problem?

TIA
0
Comment
Question by:squatex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 2

Expert Comment

by:ITG-SSNA
ID: 12360491
Install and use rdate.

crontab -e

0 * * * * /usr/sbin/rdate -s time.mit.edu

(Or wherever your path is, try 'which rdate' to see if it is already installed)

Regards,

~K Black
Irvine, Ca.
0
 
LVL 4

Author Comment

by:squatex
ID: 12361303
Thats not really what im looking for. I can get the same results with hwclock as the hardware clock is keeping time correctly. I already have a cron job which does this. Im looking for a more elegant solution.
0
 
LVL 2

Expert Comment

by:ITG-SSNA
ID: 12361409
Well linux likes to sync up system time with CMOS before it changes it's runlevel at reboot.
Therefore I'd suspect this "more elegant solution" you are looking for might come in the form
of a new CMOS battery :)

~K Black
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:squatex
ID: 12362180
The CMOS battery has been changed. Its not the hardware clock thats incorrect. The CMOS keeps perfect time.  It's the system clock. If i were to reboot (i have) right now the system time would be correct....for a few minutes. After 15 minutes the system clock would be several seconds faster than the hardware clock (which is still correct).

Like I said before, I can correct this (by running hwclock --systohc every few minutes from a cron job to sysnc the system clock to hardware - this happens during init at every boot) but I am hoping to find a better solution.

There is a utility called adjtimex that adjusts the tick frequency and latency in the kernel. Im just not sure how to get it to fix my problem. I was hoping someone could provide me with some examples.
0
 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12362598
What you need is network time protocol, its really clever syncing to an atomic clock from the internet calculating the cmos clock drift so the results get better over time. It also make minor adjustments at a time so dosnt bugger up services like cryptography

http://www.ntp.org/

0
 
LVL 6

Expert Comment

by:blkline
ID: 12362607
What I would do is reset the time again (rdate -s clock.psu.edu;hwclock --systohc), then rm /etc/adjtime.  It may be that your  time was so skewed initially that the drift adjustment is totally out of whack.  

I've had this same problem before and I fixed it using those steps.
0
 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12362620
As an added bonus you can put it on all your server and keep them all sychronised. I used to have massive problems using dns tsig until I started using ntp
0
 
LVL 23

Accepted Solution

by:
Mysidia earned 1000 total points
ID: 12367287
I think you have the right idea with adjtimex
http://www.togaware.com/linux/survivor/Using_adjtimex.shtml

Debian and possibly some other distributions provide an  adjtimexconfig  program
to automatically adjust it to within the accuracy of your hardware clock.

Running  a ntp  aka xntp or some other similar package would help keep
the clock synchronized hopefully to within a second with a time server,
but only if the system is networked.

But it may not solve the problem very well.   It's not ideal to be needing major corrections
to the system time.   If your clock is drifting _that_ much, then I wouldn't say that resyncing
with crontab is ideal.

One possible concern of "patching" a bad system clock timing is it could effect other timed things going on in the system.. i.e. if a program uses the system time during execution as reported by the kernel (registering a negative or errorful total time difference between two points if there was a huge clock drift between synchronization times causing a sudden "jump" in the current system time).

0
 
LVL 5

Expert Comment

by:paranoidcookie
ID: 12367394
ntp will use the drift statists to help keep the system clock inline even if you lose networking. Plus if you have it running on multiple ervers at least they will sync to each other and after all that is the most important thing on the network that the servers are in time sync with each other as a lot of updates use time as a frame of reference.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question