# System clock is running too fast, gain over 1sec in /hour

## Joseph_sys

On one of my Gentoo boxes system clock runs too fast, I get gain over 1sec. in 24hr.

Hot to adjust the time periodically. 

I run: adjtimexconfig and got:

```
Adjusting system time by 53.0835 sec/day to agree with CMOS clock...
```

However, the "adjtimex" utility only adjust the time on start up, isn't it?

The problem I have is the computer is not connected to the internet, so I can not use ntp and is in place workers have not much clue about Linux. 

How to fix the problem with adjusting time periodically?Last edited by Joseph_sys on Mon Dec 08, 2008 3:33 am; edited 2 times in total

----------

## tarpman

If you have an /etc/adjtime file, remove it.

----------

## Joseph_sys

 *tarpman wrote:*   

> If you have an /etc/adjtime file, remove it.

 

I did it, restarted the PC and the OS recreated a new one but I still get over 1sec. per hour advancing in time.

The system is ahead 5sec. per 4 hour so in 24houir it will be 30sec. in one month 15min. (too much);

 Any idea how to correct it automatically?

----------

## overkll

Why not use ntp?

----------

## Joseph_sys

 *overkll wrote:*   

> Why not use ntp?

 

I would definately use if if I could; the problem is the box is not connected to Internet, and is running Asterisk so accurate timing is desired as phones open/close time are based on computer timing; so 15min. advance in one month is not acceptable.

In addition the box is installed in an office where most of them don't have a cue what command prompt is.

----------

## overkll

Does this asterisk box have ANY network access?  If so, you could have it sync to a machine on the local net.

----------

## Joseph_sys

 *overkll wrote:*   

> Does this asterisk box have ANY network access?  If so, you could have it sync to a machine on the local net.

 

Yes, it is on a local network but there are only three boxes, one of them is Linksys-ATA (adapter that acts as a router), another Linksys Router running Open Source OS (White Russian.. don't remember) and one Windows98 box.

I suppose one of them would have to run NTP time server; I suppose I can install one on that White Russian - Linksys.

----------

## overkll

Or you could use a "door stop" computer like an old Pentium 166, put debian or freebsd on it with no X or graphics and make it an NTP server.  Then have the asterisk box sync with the ntp server on the local net.  Heck, you could even run Freesco on the door stop and just use it for ntp syncing.  Freesco is a linux based router that boots from a 1.44mb floppy.

If you can install ntp or the like on the linksys, then this would be mute.  I'm currently in charge of 4 linksys's WRT54G/GL's, all of which run Tomato Firmware.  I don't remember if they have an NTP server on them.

----------

## jcat

Are you saying that nothing on the LAN is allowed internet access?

If that's the case then fair enough, if not just install ntpd on the asterix box and make provisions for it to have internet access (via the Linksys or whatever) for those particular ntp ports.

I'm probably missing something crucial, but the solution seems simple..   :Smile: 

Cheers,

jcat

----------

## hvengel

 *jcat wrote:*   

> Are you saying that nothing on the LAN is allowed internet access?
> 
> If that's the case then fair enough...

 

In that case one option is to attach a local reference clock to one of the machines.  Since you have a gentoo box already it would probably be the easiest one to setup.  There are a number of options for reference clocks but the least expensive is the Garmin 18LVC (about $70 with all of the parts to attach it).  You have to do a little wiring to get this connected (a serial port and 5V power - use a USB cable for power).   But the wiring needed is very simple.     This reference clock is an all in one unit so you need to be close to a south facing widow for this to work correctly.   There is a web page (do a google search for LinuxPPS and Garmin) that has a howto for this including wiring details.

Another option is to use a Motorola Oncore as a reference clock.  New units with M12M Timing modules can be purchased from Synergy Systems for about $200 already setup and ready to attach to your computer.  You will have to install an external antenna and route the feed line to the location of the computer.  I am using a used Oncore UT+ GPS module that I wired up myself.  This is cheap to do since you can get used tested UT+ modules fgrom egbay for under $20 but more difficult than wiring up a Garmin 18LVC.  The Oncore UT, Oncore UT+, M12T, M12M Timing and VP models are timing specific GPS receivers that are extremely accurate time sources.  

You would also have to patch your kernel with the LinuxPPS patch set and hand build ntp with refclock support.  But once this was setup and running it should keep the machines clock to with in 20 microseconds of UTC.  This machine could also be configured as a time server for the local network so that all of the machine there have accurate time.

----------

