# NTPD with Sys5 init is not Continuously Synchronizing Time

## RAPHEAD

Hi,

I have a fairly recent system but after 90 days uptime I noticed that there is a time drift.

I have ntpd running:

```
/usr/sbin/ntpd -p /var/run/ntpd.pid -u ntp:ntp
```

With this config:

```
restrict default nomodify nopeer

restrict 127.0.0.1

```

The wiki says "Add ntpd to the default runlevel to have the time synchronized automatically"

http://wiki.gentoo.org/wiki/NTP

So I don't understand why it is not syncing.

Only after running ntp-client manually, the time got synced.

----------

## massimo

You have to add other NTP servers to /etc/ntp.conf.

----------

## 666threesixes666

some of the wiki was a little messed up and out of order.  some client stuff bleeding into server configs.

you don't need to add to the configs.

look at the wiki again i fixed it 4 u.

b4

https://wiki.gentoo.org/index.php?title=NTP&oldid=18801

after

https://wiki.gentoo.org/index.php?title=NTP&oldid=49167Last edited by 666threesixes666 on Fri Sep 06, 2013 5:51 pm; edited 1 time in total

----------

## RAPHEAD

Hi, 

many thanks for your support and for putting it in the wiki!

Unfortunately, I think I have ntp-client running which 

```
rc-service ntp-client status
```

 confirms.

But still there was a time drift in half a year by 6 minutes and only after restarting ntp-client manually again fixed it.

So I think that ntp-client is not synchronizing continuously.

----------

## toralf

 *RAPHEAD wrote:*   

> So I think that ntp-client is not synchronizing continuously.

 Yes.

I use this config values - they do work  since last century :

```
tfoerste@n22 ~ $ grep -v -e '^$' -e '#'  /etc/ntp.conf

server 0.gentoo.pool.ntp.org

server 1.gentoo.pool.ntp.org

server 2.gentoo.pool.ntp.org

server 3.gentoo.pool.ntp.org

driftfile       /var/lib/ntp/ntp.drift

restrict default nomodify nopeer

restrict 127.0.0.1

```

----------

## 666threesixes666

id just run the server, and remove the client / ntpdate....  id run ntpdate pool.ntp.org once, then ntpd for the long haul.

id then /etc/conf.d/hwclock

```

clock_hctosys="YES"

clock_systohc="YES"

```

&&

rc-update add hwclock boot

ive yet to wiki this.

----------

## toralf

 *666threesixes666 wrote:*   

> 
> 
> ```
> 
> clock_hctosys="YES"
> ...

 The reporter mentioned a 90 day uptime period, so although this is helpful in general it is not the root cause of his problem. The root cause is the missing external time source/s, isn't it ?

----------

## 666threesixes666

ntpdate should be called frequently from a cron job, or ntp-client should be restarted from a cron job frequently.  or run the ntpd server and have it adjust clock rates gradually all the time.  they want ntpd behavior, and to turn ntp-client / ntpdate stuff off, those are like stand alone sync right now clients.  ntpd would adjust drift rates and correct the drift and sync against online atomic clocks.

----------

## dmpogo

 *toralf wrote:*   

>  *666threesixes666 wrote:*   
> 
> ```
> 
> clock_hctosys="YES"
> ...

 

Of course, it is, it seems he does not have external time servers specified and is synchronizing just with himself.

However, one should remember that if the time mismatch is too large, ntpd will refuse to synchronize and will exit - you need to synchronize manually first.  It can happen if uptime is large with synchronization off or when system clock is not synced to hardware, so on reboot you get hardware time which is off.  So uptime and options above may have some relevance to the situation.Last edited by dmpogo on Fri Sep 06, 2013 11:02 pm; edited 1 time in total

----------

## 666threesixes666

ive seen other distributions run ntp-date to set local time, then hand over to ntpd.  (slackware)  maybe there is a method to do this, like set client to run @ boot & ntpd @ default.  (or maybe both default would do this since its alphabetical?)

"it seems he does not have external time servers specified and is synchronizing just with himself. "  he's syncing remotely once, and then never syncing or adjusting clock skew again. " it seems he does not have external time servers"  or both.

----------

## toralf

 *666threesixes666 wrote:*   

> ive seen other distributions run ntp-date to set local time, then hand over to ntpd.  (slackware)  maybe there is a method to do this

 ?

That's exactly, how it works in Gentoo - simply add ntpd and ntp-client to "default" runlevel.

----------

## dmpogo

 *666threesixes666 wrote:*   

> ive seen other distributions run ntp-date to set local time, then hand over to ntpd.  (slackware)  maybe there is a method to do this, like set client to run @ boot & ntpd @ default.  (or maybe both default would do this since its alphabetical?)
> 
> "it seems he does not have external time servers specified and is synchronizing just with himself. "  he's syncing remotely once, and then never syncing or adjusting clock skew again. " it seems he does not have external time servers"  or both.

 

 (or maybe both default would do this since its alphabetical?) 

Yep, sure,  you now openrc has things like 'after', 'need', etc.   If you look at /etc/init.d/ntpd  it says

```

depend() {

        use net dns logger

        after ntp-client

}

```

so adding both ntp-client and ntpd to default will launch them in the required sequence.

----------

## 666threesixes666

ok i think the wiki has a sufficiently proper flow to it now.

https://wiki.gentoo.org/wiki/NTP  <---

added

https://wiki.gentoo.org/wiki/NTP#Ntp-Client <---  (for those adjusting config files going to ntpd not ntp-client)Last edited by 666threesixes666 on Fri Sep 06, 2013 11:14 pm; edited 1 time in total

----------

## Jaglover

net-misc/openntpd or net-misc/ntp ?

----------

## 666threesixes666

 *Jaglover wrote:*   

> net-misc/openntpd or net-misc/ntp ?

 

net-misc/openntpd should be its own wiki page, go crazy on it i don't intend to follow through past working on the net-misc/ntp.

net-misc/ntpclient & net-misc/openntpd & net-misc/ntp could make good ntp protocol sub pages.

----------

## RAPHEAD

Hi,

I double checked with the wiki but everything is set up as documented, also the kernel settings.

I will track it and hope that it works now.

----------

