# ntp not working.



## wonslung (Sep 25, 2009)

I'm trying to get ntp working.  I've tried the suggestions in the default file /etc/ntp.conf and i've also tried adding ntp pool servers from the net, nothing works.

no matter what server i add, i get this error:


```
Error:  hostname nor servername provided, or unknown.
```

am i missing something?

i do have ntpdate_enable="YES" in my /etc/rc.conf


could this be because i use wireless?

I'm running FreeBSD 8.0 rc1

thanks


----------



## dennylin93 (Sep 25, 2009)

Uh... ntpd_enable and ntpdate_enable aren't the same. The NTP daemon syncs the clock using a more gradual approach while ntpdate syncs it immediately. The command ntpdate can't be run while the NTP daemon is enabled.

To use the NTP daemon, put ntpd_enable="YES" in /etc/rc.conf and configure /etc/ntp.conf.

As for ntpdate, try (remember to change the server)

```
ntpdate_enable="YES"
ntpdate_flags="-b time.stdtime.gov.tw"
```


----------



## wonslung (Sep 25, 2009)

i was following this from the handbook
anyways, i figured out the problem but i don't know how to solve it.

It needs to be delayed until after the wifi comes up.  If i do /etc/rc.d/ntpdate restart it syncs

i will check out what you said and see if it helps thought


----------



## dennylin93 (Sep 25, 2009)

I'm not really familiar with WiFi, but `$ rcorder /etc/rc.d/*` should show the order the startup scripts are executed. Check and see if ntpdate is behind WiFi.


----------



## wonslung (Sep 25, 2009)

i disabled ntpdate, and set up ntpd like you said but now i get this error:


```
Frequency format error in /var/db/ntpd.drift
```


----------



## DutchDaemon (Sep 25, 2009)

Just let it run for a while. The drift file is probably not populated on start-up of ntpd, so it considers the (lack of) information in it as an error. After a while, you should see a time offset (like -2.045) showing up there.


----------



## phoenix (Sep 25, 2009)

According to rcorder, ntpdate runs before wpa_supplicant, which means it will run (and fail) before the wireless link is up.

You'll want to edit /etc/rc.d/ntpdate and add "wpa_supplicant" to the REQUIRE line.

/etc/rc.d/ntpd REQUIREs ntpdate, so getting ntpdate to run after wpa_supplicant should get things working at boot.


----------



## anomie (Sep 25, 2009)

I'd also add that if this is on a laptop (I'm presuming that because of the wireless - I could be wrong), then this might be a good candidate for using the ntpd -q option. 

What I am getting at is if you're turning it off and on all the time, I don't see a good reason to have the ntpd daemon running in the background. Instead, just sync up once at boot time (after fixing the rc order).


----------



## wonslung (Sep 26, 2009)

it's working now.

It is a laptop but i do leave it on for long periods of time, the only reason i've been rebooting it lately is to make sure things were starting at boot like i want.


I've got one more issue to work out with it, but everything is is working nicely at this time.

Thanks for the help guys


----------



## phoenix (Sep 26, 2009)

For the archives, can you post what the final solution was?


----------



## wonslung (Sep 26, 2009)

I did what you suggested, i added wpa_supplicant to the REQUIRE line in /etc/rc.d/ntpdate


----------

