Solved

Fixing time drift

Posted on 2004-10-20
9
819 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 250 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now