# ntpd failing, problem with adjtimex

## pookey

My clock is drifting - it can drift 15 minutes in a day quite easily it seems - sometimes more.

NTP is failing to work, openntp too.

stracing the process shows this

```

Process 3091 attached - interrupt to quit

poll([{fd=4, events=POLLIN, revents=POLLIN}], 1, -1) = 1

read(4, "\1\0\0\0\0\0\0\0\0\0\0\0\30\0\4\10\0 \21\231a|h@", 4096) = 24

time(NULL)                              = 1184171709

stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=3661, ...}) = 0

stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=3661, ...}) = 0

stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=3661, ...}) = 0

send(3, "<30>Jul 11 17:35:09 ntpd[3091]: "..., 68, MSG_NOSIGNAL) = 68

adjtimex({modes=ADJ_OFFSET|0x8000, offset=0, freq=-34784, maxerror=16384000, esterror=16384000, status=STA_UNSYNC, constant=4, precision=1, tolerance=33554432, time={1184171709, 891933}, tick=10000, ppsfreq=0, jitter=0, shift=0, stabil=0, jitcnt=0, calcnt=0, errcnt=0, stbcnt=0}) = 5 (TIME_ERROR)

poll

```

As you can see, adjtimex() is returning a TIME_ERROR, and I can't figure it out, it's driving me mad!  :Smile: 

Any ideas?

----------

## xalan

Which ntp version are you using? What are your pool servers? See if ntpd is connecting with the servers by looking at /var/log/ntpd.log and /var/log/messages

----------

## pookey

I've tried ntp and openntp - but I think you're missing the point. It's not that ntp is failing, it's that the call to adjtimex() is returning an error.

----------

## xalan

I understood you earlier point about adjtimex, the reason I asked about ntp version, is because, I am not facing that drift issue. I am using 4.2.4_p0 without any problems. One of the main reasons for drift is that your pool servers might be down. I wanted to eliminate that factor to diagnose your problem. Once again is everything fine with your /var/log/ntpd.log. Is your ntp synchronizing with stratum servers in the first place?

----------

## pookey

I've tried both ntp and openntp, latest ~x86 versions.

ntp is working in the fact it is connecting to peers, and attempting to adjust the time, it's attempted adjustments appear in the syslog without any errors.  If it wasn't working it wouldn't be making the system call to adjust the clock would it?

Thanks

----------

## runem

Perhaps you have broken hardware. Some chipsets have bad clocks. The clock can be adjusted with tickadj but you have to work out how much the clock drifts. The way to do it is something like this:

Stop ntpd

Set the clock with ntpdate

Wait (say) 3 hours

Set the clock with ntpdate and take note of the adjustment

Work out how fast/slow the clock is over a second

Use that as input to tickadj (man tickadj)

Start ntpd and see if it works. When it does add the appropriate command to /etc/init.d/local

Search the NTP NG comp.protocols.time.ntp for more details

Regards Rune

----------

