# NTPD daemon start duplicate at boot time



## epopen (Mar 1, 2010)

Hello everybody

I have a little problem...
My laptop is FreeBSD 8.0-stable AMD64.
NTPD daemon start duplicate at boot time.(2 daemon process and different PID)
And a lot of dmesg message

```
ntpd_initres[40925]: ntpd returns a permission denied error!
```
And `ntpq -p` command can't any peer server.
But I restart ntpd by `#/etc/rc.d/ntpd restart`...
All of normal, (only 1 daemon process,And ntpq -p return a lot of peer server).
I am confused now.... I can't know how about debug.
Under is /etc/rc.conf (Make sure ntpd_enable="YES" only one)

```
ntpd_enable="YES"
ntpdate_enable="YES"
```
And /etc/ntp.conf

```
server 0.freebsd.pool.ntp.org iburst maxpoll 9
server 1.freebsd.pool.ntp.org iburst maxpoll 9
server 2.freebsd.pool.ntp.org iburst maxpoll 9
server 0.pool.ntp.org iburst maxpoll 9
server 1.pool.ntp.org iburst maxpoll 9
server pool.ntp.org iburst maxpoll 9

restrict default ignore
restrict 0.freebsd.pool.ntp.org nomodify nopeer noquery notrap 
restrict 1.freebsd.pool.ntp.org nomodify nopeer noquery notrap 
restrict 2.freebsd.pool.ntp.org nomodify nopeer noquery notrap 
restrict 0.pool.ntp.org nomodify nopeer noquery notrap 
restrict 1.pool.ntp.org nomodify nopeer noquery notrap
restrict pool.ntp.org nomodify nopeer noquery notrap
restrict 127.0.0.1 nomodify nopeer notrap
restrict -6 ::1 nomodify nopeer notrap
restrict 127.127.1.0

server 127.127.1.0
fudge 127.127.1.0 stratum 10
enable auth monitor
```

Please help me debug.
Thanks everyone very much


----------



## gilinko (Mar 1, 2010)

I have always had a lot of small problems with the system ntpd, so I switched to the openntpd port insted which is very simple and functional ntpd. Not one problems since the switch.

So my suggestion would be to stop try to get the system ntpd working and install the openntpd port insted


----------



## JimW (Mar 1, 2010)

If you are going to have both *ntpd* and *ntpdate* in your rc.conf, I'm pretty sure you must use *ntpdate* first.

E.g. ....


```
ntdate_enable="YES"
ntpdate_flags="-b"
ntpd_enable="YES"
```

The *"-b"* flag tells *ntpdate* to update and change the machine's time immediately and it looks at the /etc/ntp.conf file.

You could also specify on the *"ntpdate_flags"* line where it should look to update the machine's time.

E.g. .....


```
ntpdate_enable="YES"
ntpdate_flags="-b 0.us.pool.ntp.org"
```

The above example tells the machine to sync the time to the U.S. time server pool. You could change it with a pool in your timezone by checking this site...

http://www.pool.ntp.org/zone/@

If your machine is turned off frequently, it might be a good idea to just run *ntpdate* on startup instead of running *ntpd*.

It's said that *ntpdate* is deprecated and going to be removed soon, but it is still installed and works just fine in FreeBSD 8.0.


----------



## Ruler2112 (Mar 1, 2010)

gilinko said:
			
		

> I have always had a lot of small problems with the system ntpd, so I switched to the openntpd port insted which is very simple and functional ntpd. Not one problems since the switch.
> 
> So my suggestion would be to stop try to get the system ntpd working and install the openntpd port insted



I second this.  Took me all of about 2 minutes to get openntpd up and running flawlessly on the latest 8.0 box I built.


----------



## epopen (Mar 6, 2010)

JimW said:
			
		

> If you are going to have both *ntpd* and *ntpdate* in your rc.conf, I'm pretty sure you must use *ntpdate* first.
> 
> E.g. ....
> 
> ...


Thanks , But problem still ....
I plan install openntpd.
Thanks everyone


----------



## achix (Mar 6, 2010)

native ntpd has been working fine (for me) for many different machines/freebsd versions/years.
why don't you try with with a simple configuration /etc/ntp.conf like

```
driftfile /etc/ntp/drift
server gr.pool.ntp.org
```
?
Also, (for a start)
- disable ntpdate,
- reboot
- from BIOS set the time to the correct UTC time (check the battery while you are at it)
(bear in mind that ntpd makes a great job keeping precise time in computers but fails if the error/time difference is big enough)
- boot, and then run tzsetup(8) to set the correct TZ for your local time
- keep a simple ntp.conf 
and just see if you can get smth sane going.

if the double ntp processes persist then make your changes/tests by calls to `#  init 1` <ctl-D> sequence, you dont have to reboot the machine every time to test your multiuser boot progress.


----------



## DutchDaemon (Mar 6, 2010)

*ntpd* can't handle huge time differences in one go, it adjusts slowly, which means it can take a loooong time to catch up with the actual time; *ntpdate* can jump to any time you throw at it immediately. One should boot with ntpdate enabled to set the initial correct time (no matter how much 'off' it is), and start ntpd/openntpd straight after to keep the time synchronised.


```
ntpdate_enable="YES"
ntpdate_flags="-u -b"
ntpdate_hosts="ip.address.here"
openntpd_enable="YES"
```

It is advisable to put the IP address of an NTP server in rc.conf, because it may try to synchronise the time before DNS is available.


----------



## Kiiski (Mar 7, 2010)

Hi

 Maybe you could get what you want with


```
ntpd_enable="YES"
ntpd_sync_on_start="YES"
```

in /etc/rc.conf.

From /etc/defaults/rc.conf:


```
ntpd_sync_on_start="NO"         # Sync time on ntpd startup, even if offset is high
```


----------

