# ntp doesnt change clock

## charlie26

```
bash-2.05b$ cat /etc/ntp.conf

driftfile /var/lib/ntp/ntp.drift

server   ntp2b.mcc.ac.uk

server audaxsystems.co.uk

server  ntp.maths.tcd.ie

restrict 127.0.0.1 nomodify

logfile /var/log/ntp.log

```

ntpd finds the servers and does the sums 

```
bash-2.05b$ ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

 veracity.mcc.ac 193.63.105.18    2 u  986 1024  377   32.674  1004958 1674.11

 www.audaxsystem 193.79.237.14    2 u  791 1024  377   25.753  1005308 1729.69

 lanczos.maths.t 140.203.16.5     2 u  782 1024  377   32.339  1005334 1609.00

bash-2.05b$

```

but the computer time doesnt change - im losing about 25 minutes/day 

Ive tried ntpd-client and the same thing happens

Ive got the simplest ntpd.conf file I  can find

----------

## cazze

did you try openntp? i had more luck with that one  :Wink: 

----------

## BitJam

The problem is that ntpd won't adjust the clock if the offset is larger than some preset limit.   The solution is to run ntpdate when you system boots.  This will quickly bump your clock to the correct time so that ntpd can make fine tuning adjustments after that.    This should be run automatically at boot time by /etc/init.d/ntp-client  with the associated conf file /etc/conf.d/ntp-client.

You can run it yourself by running ntpdate at the command line.   This sudden change in the system clock can have unwanted side effects.  For example, you don't want to be running "make" when you change the clock.

----------

## jklmnop

there's something funky going on with ntp and the more recent 2.6.x kernels

like atleast .9 and .10.  none of my machines has kept time correctly with

them.  yes, i run ntp-client at boot to get correct time, then ntpd to a local

stratum 0 server and time still drifts.  some googleing seems to point to a

change in the kernel in include/asm/param.h where HZ used to be defined

as 100 and is recently defined as 1000.

```

#ifdef __KERNEL__

# define HZ             1000            /* Internal kernel timer frequency */

# define USER_HZ        100             /* .. some user interfaces are in "ticks

" */

# define CLOCKS_PER_SEC         (USER_HZ)       /* like times() */

#endif

```

some people have set this back to 100 to stop the clock drifting, some others

have played with tickadj setting for ntp.

anyway, with recent kernel it's unlikely that ntp works without tweaking

something...

----------

## charlie26

ive run ntpdate to get it right and then ntpd - the offset reported by ntpq - p graudaully increases and then ntpd bombs out because the differnece is too great 

ive tried ntp-client and openntpd as well

----------

## timmy

If you use /usr/bin/tickadj as described here, then ntpd should start working.

Tim

----------

## charlie26

is this as well as ntpd or instead of ?

----------

## timmy

 *charlie26 wrote:*   

> is this as well as ntpd or instead of ?

 

As well as.

You need to follow the instructions in the link to calculate the best value of tickadj for your machine, set it using /usr/bin/tickadj, and then run ntpd.

You might want to alter your /etc/init.d/ntpd script to set the tickadj automatically.

Tim

----------

## kernelsensei

I had exactly the same problem, commenting restrict and adding iburst in the servers list did the trick !

my ntp.conf :

```
server ntp.obspm.fr iburst

server ntp.tuxfamily.net iburst

server ntp.ndsoftwarenet.com iburst

server ntp.free.fr iburst

server ntp.via.ecp.fr iburst

server ntp1.theremailer.net iburst

server time2.one4vision.de iburst

server hora.oxixares.com iburst

server ntp.mfa.gr iburst

server timeserver.ntp.ch iburst

driftfile /var/lib/ntp/ntp.drift

logfile /var/log/ntp.log

```

----------

## Sixtiz

I've got the same problem here running a 2.6.10-gentoo-r6 on a Mac mini : ntpd won't set the time. The servers have a considerable jitter (around 3000), the offset keeps increasing and ntpd won't synchronize.

The ntpd from openntpd says it adjusts the time : I have messages like 

```
ntpd[22144]: adjusting local clock by 9.165573s
```

 in the logs, but the clock never actually gets adjusted.

I'm not sure if I want to play with tickadj, since in the manual page, it says :

 *Quote:*   

> Newer machines with precision time support, including Solaris, Tru64, FreeBSD and Linux (with PPSkit patch) should NOT use the program.

 

I think that for now, I'll just put a ntpdate in the cron...  :Crying or Very sad: 

----------

## thecooptoo

still not solved

Ive adjusted tiackadj gradually up to 1015 but it doesnt sems to chnage anything  and Ive added Iburst to the (long) list of time servers .

It seems to be loosing more slowly , bu its still loosing.

is it a bug that needs reporting ?

----------

## kernelsensei

the last chance before the bug report : Go on IRC, #ntp@irc.freenode.net and ask directly the devs .. (that's what I did ...)

----------

## pbardet

 *charlie26 wrote:*   

> ntpd finds the servers and does the sums 
> 
> ```
> bash-2.05b$ ntpq -p
> 
> ...

 

I've had a problem similar to yours. There was a combination of wrong setups that made it happen.

So far, I can't see no * in front of one of the servers. It means that no server is used to do the sync.

In my case, my kernel was improperly compiled with two different IDE chipsets that prevented

the DMA use. That would slow down the machine and end up with a similar time loss per day.

Second problem was permission on log file, set to root, instead of ntp:ntp, which would make

ntpd crash silently. I can't remember though if ntpq would be able to report server list, since it did

at some point and then started to give error messages later.

----------

## kernelsensei

3 servers is not good, because ntp can't determine which one is the best, the devels told me that .

You have 2 choices :

- Only 1 server

- >= 4 servers

and dont forget the "iburst" on the server line in the config file ...

----------

## pbardet

Weird, as I have 3 servers and it works fine now.

On my gentoo box, I've setup 3 servers from Canada.

On my FC3 box, I'm using the ntp.org servers that change every month.

Both work fine

----------

## jdgill0

I left my server line as

```
server pool.ntp.org
```

Nor do I have iburst, and I have

```
restrict default nomodify nopeer

restrict 127.0.0.1

```

All has been working fine, but is this good or bad?

----------

## pbardet

From what I undersatand, pool.ntp.org points to anywhere in the world so it may be less accurate (http://www.pool.ntp.org/#use).

I've seen some people usint us.pool.ntp.org, or something similar, specifying to use any US server.

I don't know if it's still possible and if I could put a ca.pool.ntp.org in my setup.

So far, with both boxes side by side, if I type date and hit the return key at the same time (as if both my hands could be sync'ed  :Wink: ), both clocks give me the same result, +- 1s.

I suppose it doesn't really matter until you start compiling across the network where sometimes make gets confused if both clocks are not the same.

Since I currently compile only on local machines, I'm not bothered by this.

----------

## augury

i do three ntpdates and 

rm /etc/localtime 

ln -sf /usr/share/zoneinfo/posix/America/New_York /etc/localtime

hwclock --localtime --systohc

and my clock stay normal.

----------

## nichocouk

 *pbardet wrote:*   

>  *charlie26 wrote:*   ntpd finds the servers and does the sums 
> 
> ```
> bash-2.05b$ ntpq -p
> 
> ...

 

I've got the same problem, with ntpq -c pe reporting 3 servers (I've added 2 more now and will check if that changes anything) but not a single star. I do the ntp-client to set the clock at boot time and ntpd to sync, but it does not sync. This is a serious problem for me as I often run codes that lead to a very heavy CPU load and my clock drifts a lot.  :Sad: 

Sorry for the noob question, but how do you check / change the permission to the log file to ntp:ntp?

----------

## pbardet

To check:

```
ls -l /var/log/ntp.log
```

will show you which user the file belongs to.

If it shows root, this is wrong.

It should show ntp    ntp.

To change:

```
chown ntp:ntp /var/log/ntp.log
```

----------

## pbardet

You can also check if ntpd runs fine with

```
ps waux | grep ntpd
```

which should return 2 different lines

one with grep ntpd on it

the other one with ntpd + parameters. If that second line does not appear, ntpd crashed.

----------

## nichocouk

Since I've added 2 more servers in my ntp.conf file (now I have 5 servers) it seems to be able to sync with one of them:

```
# ntpq -c pe

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

+110.Red-80-33-1 83.246.118.20    3 u   25   64  377  134.678  -17.093   4.090

+ns1.pulsation.f 194.2.0.58       3 u   29   64  377   63.502   -8.056   4.368

*Time1.Stupi.SE  .PPS.            1 u   27   64  377   79.886   -9.168 120.519

```

I've checked the permissions on ntp.log and they were set to root. I've changed them to ntp:ntp. However it seems that I could still get some messages in the log file. 

By the way, since I restarted ntpd, here is what I get in my ntp.log file:

```

25 Apr 17:02:07 ntpd[19256]: synchronized to 192.36.143.150, stratum=1

25 Apr 17:02:07 ntpd[19256]: kernel time sync disabled 0041

25 Apr 17:13:55 ntpd[19256]: kernel time sync enabled 0001

```

What is the signigfication of the last two lines?

----------

