# nptd



## mikepwagner (Oct 26, 2016)

It's actually 10:02 PM on October 25, but the computer thinks it's four hours later:

```
michael@freebsd:/var/log % date
Wed Oct 26 02:03:23 EDT 2016
michael@freebsd:/var/log %
```
I think that means that the BIOS is set to UTC, but the computer thinks it's set to EDT.

I thought that maybe ntpd would solve this issue, but I can't even tell if ntpd is running.

It looks like it started when I rebooted:

```
michael@freebsd:/var/log % grep ntpd messages
Oct 26 01:13:06 freebsd michael: /etc/rc.d/ntpd: WARNING: failed to start ntpd
Oct 26 01:42:33 freebsd ntpd[967]: ntpd 4.2.8p8-a (1): Starting
Oct 26 01:42:33 freebsd ntpd[968]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
Oct 26 01:42:33 freebsd ntpd[968]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2017-06-01T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
michael@freebsd:/var/log %
```
But I don't see it running:

```
michael@freebsd:/var/log % ps aux | grep ntp
michael    2263   0.0  0.0  14796   2496  0  S+   03:14     0:00.00 grep ntp
michael@freebsd:/var/log % sudo ps aux | grep ntp
Password:
michael    2265   0.0  0.0  14796   2496  0  S+   03:14     0:00.00 grep ntp
michael@freebsd:/var/log %
```
service says it's enabled:

```
michael@freebsd:/var/log % service -e
/etc/rc.d/hostid
/etc/rc.d/hostid_save
//...
/etc/rc.d/ntpd
//...
```


----------



## SirDice (Oct 26, 2016)

mikepwagner said:


> I think that means that the BIOS is set to UTC, but the computer thinks it's set to EDT.


Did you set your timezone correctly? Run tzsetup(8).


----------



## kpa (Oct 26, 2016)

Take a look at /etc/ntpd.conf and see if it looks sane.


----------



## xtaz (Oct 26, 2016)

I think ntpd exits if the time difference is too high for it to correct. In that case try `ntpdate -u pool.ntp.org` which would set the time in a large jump.


----------



## sko (Oct 26, 2016)

xtaz said:


> I think ntpd exits if the time difference is too high for it to correct. In that case try `ntpdate -u pool.ntp.org` which would set the time in a large jump.



`-u` just uses an unprivileged port so you don't have to stop ntpd first. `-b` forces the time to be set immediately instead of in slow increments (which can take days or weeks!).


----------



## mikepwagner (Oct 26, 2016)

Thanks for all the answers. Poking around on the web, it looks like timedatectl is recommended over ntpdate. Does that make sense?


----------



## Uniballer (Oct 26, 2016)

No.  Not on FreeBSD.  Use ntpd like the previous posters suggested.


----------



## IPTRACE (Oct 26, 2016)

I had incorrectly dates and times using ntpdate as server and as client.
I've changed to openntpd and everything works great.


----------



## mikepwagner (Oct 27, 2016)

`ntpdate -u -b pool.ntp.org` fixed it. Thanks to all!


----------



## wblock@ (Oct 27, 2016)

`ntpdate` used to be considered obsolete and deprecated.  Did it get a reprieve?

The equivalent for ntpd(8) is `ntpd -g -q [i]servername[/i]`.


----------



## ABV (Oct 28, 2016)

Basically, ntpd is the daemon and ntpdate is the interactive application. If you don't want to run a daemon all the time, ntpdate can be run manually or as a cronjob to update the time. I think that in this case, the config file for ntpd had an option set for the maximum time jump that it would allow. Because ntpdate does not read the ntpd.conf file, there was no option set and thus it was allowed to jump the clock four hours.

For future reference, that option in ntpd.conf is `panic` and it's in seconds. If you set it to 0 it will disable the function and will allow ntpd to change the system clock by any amount.


----------



## free-and-bsd (Oct 29, 2016)

Just fixed that for myself. It actually included 2 steps: set up timezone correctly, then set up ntpd with these two rc.conf options:

```
ntpd_enable="YES"
ntpd_sync_on_start="YES"
```
Then editing /etc/ntp.conf (not /etc/ntpd.conf !) proved to be optional, the only thing I changed there was about the leap file location.


----------

