# openntpd newbie question

## meyer37

Hi all,

Just emerge openntpd on my system and changed my /etc/ntp.conf to the following:

```
#

# Sample ntpd.conf

# $Id: ntpd.conf,v 1.2 2004/07/17 00:22:19 dtucker Exp $

#

# Adresses to listen on (ntpd does not listen by default)

#listen on *

listen on 127.0.0.1

# listen on ::1

# use a random selection of 8 public stratum 2 servers

# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers

# servers pool.ntp.org

# Sync to the first active address these resolve to

server us.pool.ntp.org

```

I then ran the following:

```
rc-update add openntpd default

/etc/init.d/openntpd start
```

I have observed the following messages in /var/log/daemon.log

```
Oct 20 10:17:47 ntpd[18508]: listening on 127.0.0.1

Oct 20 10:17:47 ntpd[18508]: ntp engine ready

Oct 20 10:18:03 ntpd[18508]: peer 64.115.129.106 now valid

Oct 20 10:18:52 ntpd[18507]: adjusting local clock by 758.924814s

Oct 20 10:19:52 ntpd[18507]: adjusting local clock by 758.885385s

Oct 20 10:23:27 ntpd[18507]: adjusting local clock by 758.771882s

Oct 20 10:27:30 ntpd[18507]: adjusting local clock by 758.712684s
```

Yet when I run date I have not observed the 12 minute difference/adjustment that has claimed to have happened.

When will I see the change or do I need to do something else to actually change to the correct date and time?

----------

## fleed

do 

```
ntpdate -d servername
```

 and check what it says.

----------

## Mos

fleed: meyer uses openntpd which has a very simple setup and it does not have the "ntpdate" command like the normal ntp(d).

Meyer: I'm noticing the same, there's even a bug report for it at 

https://bugs.gentoo.org/show_bug.cgi?id=65267

It seems you just have to wait and see it slowly drift towards the right time.

----------

## meyer37

Thanks Mos, that is what I was assuming, but I figured that a simple post wouldn't hurt.

----------

## meyer37

I have been monitoring openntpd and it has slowly been adjusting the time.  One huge problem is that the machine was restarted and the time was converted back to over 10 minutes off again.  What can I do to have the system maintain the time if a reboot occurs?

----------

## Andersson

In the older ntpd package, there was a script /etc/init.d/ntp-client to set the time correct before starting the ntp daemon. I don't see a script like that for openntp. I suppose because openntp was written by the openBSD team, and you know those BSD machines never reboot  :Rolling Eyes: 

I guess it wouldn't be too hard to write one, if you just had a command to give you the time from a reliable source...

edit: how about a simple rdate -s [time server] before starting openntpd?

edit 2: what about this? I've only tried it once, but it seems to work. I just copied the dependencies from the openntpd script and added "before openntpd."

```
#!/sbin/runscript

depend() {

        need net

        use dns logger

        before openntpd

}

start() {

        ebegin "Setting system time using rdate"

        rdate -s $TIMESERVER

        eend $?

}
```

Emerge rdate, put this script in /etc/init.d/ and name it suitably (I called it set_time), edit it (replace $TIMESERVER with a timeserver), then run rc-update add set_time default.

Two things to note: the configuration (the timeserver) should be kept in /etc/conf.d/set_time for consistency with the other initscripts. That file will be sourced automatically if it exists, according to the docs, so just put TIMESERVER=time.server.whatever in there if you like. If you do, please change the CAPS to lower case.  :Smile: 

Also, your ntp server might not work with rdate, as ntp and rdate use different protocols. You may have to find another time server. (If your normal ntp server does work, you could replace TIMESERVER with something like `cat /etc/ntpd.conf | egrep ^server | head -n 1 | sed -s 's/server //'` and you'll only need one configuration file.)

If you want to change anything here, have a look at man rdate and the Gentoo Initscripts documentation.

----------

## newjosch

reboot should not be a problem.

in the standard gentoo setup there is a script '/etc/init.d/clock' that syncs the system time from the kernel-clock ( which is kept synchronzed by your ntpd ) to the hardware-clock ( on the maonboard ) before shutting down.

After startup the same script reads the time from your hardware-clock and syncs now the system -time from it.

Of course, if your hardware clock is not very accurate and the system is off for a longer period then you will have a bigger discrepancy.

But this could be corrected with hwclock and the file /etc/adjtime.

'man hwclock' tells you how to do this.

good luck

joerg

----------

## nutznboltz

How to have OpenNTPd and ntpdate? I ended up cheating like crazy.  I ran "emerge libcap" and then copied /usr/bin/ntpdate from a box with full NTP installed.

----------

## cgmd

I, too, have emerged openntpd and tried to set it up. Instructions seem sparse... :Sad: 

I have witnessed no correction in the system time. How can I troubleshoot this?

Thanks...

----------

