Time Is UTC, but Time Zone Is Local

I'll run # ntpdate 0.freebsd.pool.ntp.org as a last resort because that seems like manually setting the clock. I would prefer to get my clock fixed so the system automatically sets the time.

I take it because service ntpd status doesn't alter the state of the whole system (see below), you wanted me to run it as a regular user, not root. But, still, shouldn't that command have returned that ntpd is running?

Also, you can ignore the part in my last reply where I ask if I should run service ntpd start and if I should run the command as root. It is my understanding, based on my other thread, that that command would want to be run as root, but also that ntpd should have automatically started after the first reboot, anyway.

You'll soon get a feeling for this. As a rule of thumb: All commands which alter the state of the whole system need root privileges.
Thanks!

From my vantage point, at this point the issue seems like it's with ntpd. I did run # service ntpd status as root (I take it this was safe, but it's probably better to run that command as a regular user), and it still says it's not running.

The cool thing about sysrc(8) is that you can run it as many times as you want. All this does it making sure ntpd_enable="YES" is set in rc.conf, if it's already there it won't change anything. If it's not, it will get added.
I will try running that command then. But would a better way for writing the command/syntax be # sysrc ntpd_enable="YES" (note the quotation marks)? I just see that's how the other lines are written in /etc/rc.conf. Thanks for the rest of your post; I read it after I had already begun writing my reply.
 
I'll run # ntpdate 0.freebsd.pool.ntp.org as a last resort because that seems like manually setting the clock. I would prefer to get my clock fixed so the system automatically sets the time.
Yes, and the best approach to get your clock fixed is to run that ntpdate(8) command manually once, just to get the clock in sync now. Then let ntpd(8) do it's magic by keeping it synced in the background.
But would a better way for writing the command/syntax be # sysrc ntpd_enable="YES" (note the quotation marks)?
In this case it actually doesn't matter if there are quotation marks around it. But for the sake of consistency, yeah, sure.

From my vantage point, at this point the issue seems like it's with ntpd. I did run # service ntpd status as root (I take it this was safe, but it's probably better to run that command as a regular user), and it still says it's not running.
If you try to start it and it's already running it will tell you it's already running, yes, it's safe to do. If it starts, or at least says it has started the service, and you do a service ntpd status it should tell you it was started and is running. If it's not running, it failed to start for some reason. Most likely cause of that is a typo or error in /etc/ntp.conf. The default config should be fine, it's not perfect but it shouldn't cause errors.

To get the best results from NTP you need to look up a more 'local' NTP service. You can find them here: https://www.pool.ntp.org/zone/
 
I just ran # sysrc ntpd_enable="YES". It returned ntpd_enable: YES -> YES. After rebooting, the clock is still set to UTC. % service ntpd status still returns ntpd is not running..
 
Yes, and the best approach to get your clock fixed is to run that ntpdate(8) command manually once, just to get the clock in sync now. Then let ntpd(8) do it's magic by keeping it synced in the background.
I thought it would just be easier to tell if ntpd is fixed by seeing if my computer displays an accurate time. Shouldn't ntpd run each time at boot (re: "in the background")?

If you try to start it and it's already running it will tell you it's already running, yes, it's safe to do. If it starts, or at least says it has started the service, and you do a service ntpd status it should tell you it was started and is running. If it's not running, it failed to start for some reason. Most likely cause of that is a typo or error in /etc/ntp.conf. The default config should be fine, it's not perfect but it shouldn't cause errors.
Note that I haven't tried manually starting the service. Should I try running # service ntpd start (probably unneccessary because it should automatically start at boot)?

So do you think the problem lies with the file /etc/ntp.conf? I don't believe I made any edits to that file. How would I go about investigating and fixing this issue.

To get the best results from NTP you need to look up a more 'local' NTP service. You can find them here: https://www.pool.ntp.org/zone/
So are you saying it would be better to run # ntpdate 0.us.pool.ntp.org than # ntpdate 0.freebsd.pool.ntp.org?

I should say at this point that I did not enable the ntpdate service in the system configuration when I installed FreeBSD. I chose not to enable this service because the Handbook says:
ntpdate - Enable the automatic clock synchronization at boot time. The functionality of this program is now available in the ntpd(8) daemon. After a suitable period of mourning, the ntpdate(8) utility will be retired.

To me, that sounded like it was an old service and I should just use ntpd instead. Do you think this could be the problem? If so, is there any way to enable the ntpdate service now, or should I reinstall FreeBSD?
 
I thought it would just be easier to tell if ntpd is fixed by seeing if my computer displays an accurate time.
Yes, but the problem is that ntpd(8) won't make that change if the 'jump' in time is too big.
Should I try running # service ntpd start (probably unneccessary because it should automatically start at boot)?
If you have ntpd_enable="YES" in rc.conf, then yes, it should have started at boot. Check if it's running with service ntpd status. Or ps -aux | grep ntp

To me, that sounded like it was an old service and I should just use ntpd instead.
Yes, using ntpdate(8) as a service (in other words *_enable it in rc.conf), but it's still useful as a quick command to run.

If so, is there any way to enable the ntpdate service now, or should I reinstall FreeBSD?
No need to reinstall. Just run, in order, tzsetup (set your timezone correctly). ntpdate 0.us.pool.ntp.org (this might give a big jump forwards or backwards in time). Then check if ntpd(8) is running and enabled in rc.conf, restart it just to be sure service ntpd restart.

Now, the date(1) command should give you a proper time and date. You don't need to do anything else. It takes a bit of time for ntpd(8) to 'settle' down. Time keeping is serious business. Just keep an eye on date(1) (or some other application that shows the time).

You can periodically do ntpdate -q 0.us.pool.ntp.org to see how far off the mark your local clock is compared to the internet time source.
 
I thought it would just be easier to tell if ntpd is fixed by seeing if my computer displays an accurate time.
I like to use the ntpq(8) command to see the details of how my NTP daemon is working. Note that this command is not available for Opentpd. Here's the output of the ntpq(8) "peers" command on my server that uses the default ntp.conf(5):
Code:
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.freebsd.pool. .POOL.          16 p    -   64    0    0.000   +0.000   0.000
+69.130.244.141  64.250.105.228   3 u  484 1024  377   57.233   +1.569   2.763
-ntp3.junkemailf 216.218.254.202  2 u  395 1024  377    4.066   +3.138  30.650
+mail.eaanderson 130.207.244.240  2 u  402 1024  377   48.850   +3.867   0.945
*c-73-239-136-18 50.35.73.228     2 u   71 1024  377   40.531   -2.036   1.455
-jane.qotw.net   42.20.202.230    2 u  791 1024  377   48.876   +4.827   0.846
As you can see, my clock is offset by 2 milliseconds from its peer. The characters to the left of the servers' names are their status. The character "*" means peer, "+" means candidate, and "-" means outlier. You can see more details with the "associations" command:
Code:
ntpq> as
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 34431  8811   yes  none  none    reject    mobilize  1
  2 34432  14fa    no   yes  none candidate    sys_peer 15
  3 34433  13fa    no   yes  none   outlier    sys_peer 15
  4 34434  14fa    no   yes  none candidate    sys_peer 15
  5 34435  16fa    no   yes  none  sys.peer    sys_peer 15
  6 34436  13fa    no   yes  none   outlier    sys_peer 15
Exit ntpq(8) with "quit" or just "q".
To me, that sounded like it was an old service and I should just use ntpd instead. Do you think this could be the problem? If so, is there any way to enable the ntpdate service now, or should I reinstall FreeBSD?
They do different things. The ntpdate(8) command sets the date and time abruptly all at once. Time may actually appear to go backwards by a non-trivial amount. Many daemons cannot cope with this relativistic impossibility and crash. This is why it should only be run at boot. The ntpd(8) daemon will gradually slew the time to get it closer to the reference clock's time. How this is done varies by operating system, but basically the system clock will be very gradually slowed down or sped up to adjust the time.

The ntpdate(8) utility is based on a very old version of Ntpd, and can be replaced with ntpd -q -g. That has been the plan for some time now, but hasn't happened for some reason.
 
Yes, using ntpdate(8) as a service (in other words *_enable it in rc.conf), but it's still useful as a quick command to run.
It looks like you meant to agree on something about "using ntpdate(8) as a service." Did you mean to say it's old or obsolete?

No need to reinstall. Just run, in order, tzsetup (set your timezone correctly). ntpdate 0.us.pool.ntp.org (this might give a big jump forwards or backwards in time). Then check if ntpd(8) is running and enabled in rc.conf, restart it just to be sure service ntpd restart.

Now, the date(1) command should give you a proper time and date. You don't need to do anything else. It takes a bit of time for ntpd(8) to 'settle' down. Time keeping is serious business. Just keep an eye on date(1) (or some other application that shows the time).

You can periodically do ntpdate -q 0.us.pool.ntp.org to see how far off the mark your local clock is compared to the internet time source.
I didn't think there was any need to reinstall, but it's frustrating that there hasn't been an easy fix.

I didn't run # tzsetup because I already ran it earlier today. I did run # ntpdate 0.us.pool.ntp.org (as root), and that set the clock to the correct date and time. I then ran % service ntpd status (as a regular user), and it still returned ntpd is not running.. So I did as you said and ran # service ntpd restart (I take it I was supposed to run this command as root because it does something that affects the entire system), and it returned:
ntpd not running? (check /var/db/ntp/ntpd.pid).
Starting ntpd.

When I exited the root account and ran % service ntpd status (as a regular user), it still returns that ntpd is not running..

So the issue remains that ntpd is not running

I like to use the ntpq(8) command to see the details of how my NTP daemon is working. Note that this command is not available for Opentpd. Here's the output of the ntpq(8) "peers" command on my server that uses the default ntp.conf(5):
Code:
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.freebsd.pool. .POOL.          16 p    -   64    0    0.000   +0.000   0.000
+69.130.244.141  64.250.105.228   3 u  484 1024  377   57.233   +1.569   2.763
-ntp3.junkemailf 216.218.254.202  2 u  395 1024  377    4.066   +3.138  30.650
+mail.eaanderson 130.207.244.240  2 u  402 1024  377   48.850   +3.867   0.945
*c-73-239-136-18 50.35.73.228     2 u   71 1024  377   40.531   -2.036   1.455
-jane.qotw.net   42.20.202.230    2 u  791 1024  377   48.876   +4.827   0.846
As you can see, my clock is offset by 2 milliseconds from its peer. The characters to the left of the servers' names are their status. The character "*" means peer, "+" means candidate, and "-" means outlier. You can see more details with the "associations" command:
Code:
ntpq> as
ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 34431  8811   yes  none  none    reject    mobilize  1
  2 34432  14fa    no   yes  none candidate    sys_peer 15
  3 34433  13fa    no   yes  none   outlier    sys_peer 15
  4 34434  14fa    no   yes  none candidate    sys_peer 15
  5 34435  16fa    no   yes  none  sys.peer    sys_peer 15
  6 34436  13fa    no   yes  none   outlier    sys_peer 15
Exit ntpq(8) with "quit" or just "q".

They do different things. The ntpdate(8) command sets the date and time abruptly all at once. Time may actually appear to go backwards by a non-trivial amount. Many daemons cannot cope with this relativistic impossibility and crash. This is why it should only be run at boot. The ntpd(8) daemon will gradually slew the time to get it closer to the reference clock's time. How this is done varies by operating system, but basically the system clock will be very gradually slowed down or sped up to adjust the time.

The ntpdate(8) utility is based on a very old version of Ntpd, and can be replaced with ntpd -q -g. That has been the plan for some time now, but hasn't happened for some reason.
Thanks. This was all useful information that I, as a newbie, appreciate.
 
When I exited the root account and ran % service ntpd status (as a regular user), it still returns that ntpd is not running..
That should work though:
Code:
> service ntpd status
ntpd is running as pid 91687.

Check if it's running with ps -aux | grep ntp, you should see something like this:
Code:
> ps -aux | grep ntp
ntpd   91687    0.0  0.0    18908    5820  -  Ss   10:37         0:03.97 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f
dice  41645    0.0  0.0    11360    2428  0  R+   10:20         0:00.00 grep ntp

If none of these show ntpd(8) is running something is causing it to fail to start.
 
Check if it's running with ps -aux | grep ntp, you should see something like this:
Code:
> ps -aux | grep ntp
ntpd   91687    0.0  0.0    18908    5820  -  Ss   10:37         0:03.97 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f
dice  41645    0.0  0.0    11360    2428  0  R+   10:20         0:00.00 grep ntp

If none of these show ntpd(8) is running something is causing it to fail to start.
The first time I ran that command I got a bunch of stuff relating to Firefox, so I closed Firefox with nothing else open and ran it again. This time, it returned:
Code:
% ps -aux | grep ntp
<myusername> 46347  0.0  0.0     12868   2428  1  S+   08:23   0:00.00 grep ntp
Where <myusername> is my username.

I take it this means something is causing ntpd to fail to start. Do you have any ideas why, or is this subject for another thread?
 
Most likely cause is an error in /etc/ntp.conf. Can you post yours?
I ran # ee /etc/ntp.conf as root. Could I also have run % ee /etc/ntp.conf as a regular user, since I am only viewing--not editing--a file? I still make the mistake of doing Ctrl-C to copy when I am in a terminal, and I don't want to mess up stuff. Anyway, here's my /etc/ntp.conf file:

Code:
#
# $FreeBSD$
#
# Default NTP servers for the FreeBSD operating system.
#
# Don't forget to enable ntpd in /etc/rc.conf with:
# ntpd_enable="YES"
#
# The driftfile is by default /var/db/ntpd.drift, check
# /etc/defaults/rc.conf on how to change the location.
#

#
# Set the target and limit for adding servers configured via pool statements
# or discovered dynamically via mechanisms such as broadcast and manycast.
# Ntpd automatically adds maxclock-1 servers from configured pools, and may
# add as many as maxclock*2 if necessary to ensure that at least minclock
# servers are providing good consistent time.
#
tos minclock 3 maxclock 6

#
# The following pool statement will give you a random set of NTP servers
# geographically close to you.  A single pool statement adds multiple
# servers from the pool, according to the tos minclock/maxclock targets.
# See http://www.pool.ntp.org/ for details.  Note, pool.ntp.org encourages
# users with a static IP and good upstream NTP servers to add a server
# to the pool. See http://www.pool.ntp.org/join.html if you are interested.
#
# The option `iburst' is used for faster initial synchronization.
#
pool 0.freebsd.pool.ntp.org iburst

#
# If you want to pick yourself which country's public NTP server
# you want to sync against, comment out the above pool, uncomment
# the next one, and replace CC with the country's abbreviation.
# Make sure that the hostname resolves to a proper IP address!
#
# pool 0.CC.pool.ntp.org iburst

#
# To configure a specific server, such as an organization-wide local
# server, add lines similar to the following.  One or more specific
# servers can be configured in addition to, or instead of, any server
# pools specified above.  When both are configured, ntpd first adds all
# the specific servers, then adds servers from the pool until the tos
# minclock/maxclock targets are met.
#
#server time.my-internal.org iburst

#
# Security:
#
# By default, only allow time queries and block all other requests
# from unauthenticated clients.
#
# The "restrict source" line allows peers to be mobilized when added by
# ntpd from a pool, but does not enable mobilizing a new peer association
# by other dynamic means (broadcast, manycast, ntpq commands, etc).
#
# See http://support.ntp.org/bin/view/Support/AccessRestrictions
# for more information.
#
restrict default limited kod nomodify notrap noquery nopeer
restrict source  limited kod nomodify notrap noquery

#
# Alternatively, the following rules would block all unauthorized access.
#
#restrict default ignore
#
# In this case, all remote NTP time servers also need to be explicitly
# allowed or they would not be able to exchange time information with
# this server.
#
# Please note that this example doesn't work for the servers in
# the pool.ntp.org domain since they return multiple A records.
#
#restrict 0.pool.ntp.org nomodify nopeer noquery notrap
#restrict 1.pool.ntp.org nomodify nopeer noquery notrap
#restrict 2.pool.ntp.org nomodify nopeer noquery notrap
#
# The following settings allow unrestricted access from the localhost
restrict 127.0.0.1
restrict ::1

#
# If a server loses sync with all upstream servers, NTP clients
# no longer follow that server. The local clock can be configured
# to provide a time source when this happens, but it should usually
# be configured on just one server on a network. For more details see
# http://support.ntp.org/bin/view/Support/UndisciplinedLocalClock
# The use of Orphan Mode may be preferable.
#
#server 127.127.1.0
#fudge 127.127.1.0 stratum 10

# See http://support.ntp.org/bin/view/Support/ConfiguringNTP#Section_6.14.
# for documentation regarding leapfile. Updates to the file can be obtained
# from ftp://time.nist.gov/pub/ or ftp://tycho.usno.navy.mil/pub/ntp/.
# Use either leapfile in /etc/ntp or periodically updated leapfile in /var/db.
#leapfile "/etc/ntp/leap-seconds"
leapfile "/var/db/ntpd.leap-seconds.list"

# Specify the number of megabytes of memory that should be allocated and
# locked. -1 (default) means "do not lock the process into memory".
# 0 means "lock whatever memory the process wants into memory". Any other
# number means to lock up to that number of megabytes into memory.
# 0 may result in a segfault when ASLR with stack gap randomization
# is enabled.
#rlimit memlock 32
 
If FreeBSD is the only presently installed OS:

Reboot. Enter BIOS setup. Set the time. Add six hours to your wall-clock, and set that time. Error of no more than two minutes (I think) is okay. Reminder: It's presently evening, so you'll probably need "tomorrow's" date. Save and exit setup.

That probably fixes you. If not, run tzsetup as root again, and reply "Yes" to the first question, about whether the CMOS clock is set to UTC. Note that tzsetup doesn't clear some terminals on exit; if you can see yourself typing clear<enter> on-screen, tzsetup fully finished. Once this is all done, ntpd will probably start and stay running after boot, as expected.

FreeBSD can easily handle a CMOS clock set to local as well, but honestly it's harder for most humans to set up that way. I do admit that forgetting to add time to the wall-clock when setting time in BIOS still catches me sometimes to this day, tho.

If Windows or DOS is installed as well:

Set BIOS time directly from wall-clock, then answer "No" to first question in tzsetup. Yes, there's a registry setting that would let you use a UTC CMOS clock with Windows, but personally I'd keep it the way most other people have it until UTC finally becomes the default there.

If you have some other, additional OS installed:

Personally, I'd change them over to starting with a UTC-CMOS-clock. Opinions vary.

Future installations not Windows or DOS should be set for UTC-CMOS-clock.
 
roarde Welcome to the Forums! Thanks for the post, but I think the issue actually lies with ntpd failing to start.

grahamperrin Thanks for confirming. I suspected the file was normal, since I just installed FreeBSD and never edited the file. The issue regarding ntpd failing to start is perhaps for a new thread. In the meantime, I am fine manually setting my computer's clock (via # ntpdate 0.us.pool.ntp.org). I also have some unanswered post-installation questions in my "Best (and Most Correct)" thread, so I will probably look into those first.
 
As root, could you execute and show the output of the following commands:
ls -l /var/db/ntp/ntpd.pid

Check if ntpd is not running with:
ps -auxww | grep ntpd

Start ntpd manually and not via the service command (note: this is one line!):
/usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log

The -D and the -l option should generate a log file. Check if ntpd is running:
ps -auxww | grep ntpd

Because of your problems, ntpd may not have started but, hopefully the logfile will help us:
cat /var/log/ntp.log
 
As root, could you execute and show the output of the following commands:
ls -l /var/db/ntp/ntpd.pid
You wanted me to run all of the commands as root, correct? I did (and my command prompt of # should reflect that). Someone please let me know if it was unsafe to run any of these commands or post their output. I replaced my hostname with <hostname> and username with <username>. Anyway, here it goes:

Code:
root@<hostname>:/home/<username> # ls -l /var/db/ntp/ntpd.pid
-rw-r--r--  1 ntpd  ntpd  5 Dec  4 17:54 /var/db/ntp/ntpd.pid

Check if ntpd is not running with:
ps -auxww | grep ntpd
Code:
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
ntpd       37721   0.0  0.1     21864   6620  -  Ss   17:54     0:00.21 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift
root       56657   0.0  0.0     12868   2440  1  S+   19:15     0:00.00 grep ntpd

Start ntpd manually and not via the service command (note: this is one line!):
/usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log
Code:
root@<hostname>:/home/<username> # /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log

The -D and the -l option should generate a log file. Check if ntpd is running:
ps -auxww | grep ntpd
Code:
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
ntpd       37721   0.0  0.1     21864   6620  -  Ss   17:54     0:00.23 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift
root       60960   0.0  0.0     12868   2440  1  S+   19:23     0:00.00 grep ntpd

Because of your problems, ntpd may not have started but, hopefully the logfile will give us some help:
cat /var/log/ntp.log
Code:
root@<hostname>:/home/<username> # cat /var/log/ntp.log
 4 Dec 19:19:05 ntpd[57144]: ntpd 4.2.8p15-a (1): Starting
 4 Dec 19:19:05 ntpd[57144]: Command line: /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log
 4 Dec 19:19:05 ntpd[57144]: ----------------------------------------------------
 4 Dec 19:19:05 ntpd[57144]: ntp-4 is maintained by Network Time Foundation,
 4 Dec 19:19:05 ntpd[57144]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
 4 Dec 19:19:05 ntpd[57144]: corporation.  Support and training for ntp-4 are
 4 Dec 19:19:05 ntpd[57144]: available at https://www.nwtime.org/support
 4 Dec 19:19:05 ntpd[57144]: ----------------------------------------------------
 4 Dec 19:19:05 ntpd[57676]: proto: precision = 0.190 usec (-22)
 4 Dec 19:19:05 ntpd[57676]: basedate set to 2018-08-07
 4 Dec 19:19:05 ntpd[57676]: gps base set to 2018-08-12 (week 2014)
 4 Dec 19:19:05 ntpd[57676]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
 4 Dec 19:19:05 ntpd[57676]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2022-06-28T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
 4 Dec 19:19:05 ntpd[57676]: unable to bind to wildcard address :: - another process may be running - EXITING
 
Yes, you understood correctly, as root.

You already had a ntpd running; that is why you saw:
4 Dec 19:19:05 ntpd[57676]: unable to bind to wildcard address :: - another process may be running - EXITING

I suspect there is something wrong with the ntpd.pid file, please show its contents:
ps -auxww | grep ntpd
cat /var/db/ntp/ntpd.pid
 
Yes, you understood correctly, as root.

You already had a ntpd running; that is why you saw:
4 Dec 19:19:05 ntpd[57676]: unable to bind to wildcard address :: - another process may be running - EXITING

I suspect there is something wrong with the ntpd.pid file, please show its contents:
ps -auxww | grep ntpd
You wanted me to run these next two commands as root as well, correct? I am new to Unix, so I need to know when I should run commands as root. Needless to say, I did run them as root. Here it goes:

Code:
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
ntpd       70107   0.0  0.1     21864   6552  -  Ss   19:54    0:00.02 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift
root       89891   0.0  0.0     12868   2440  1  S+   19:59    0:00.00 grep ntpd

cat /var/db/ntp/ntpd.pid
Code:
root@<hostname>:/home/<username> # cat /var/db/ntp/ntpd.pid
70107root@<hostname>:/home/<username> #

I included the next new command prompt line because the "70107" seemed unexpected and significant. Do you know what that means?

Edit: Note that I did restart my computer between this post and my last post.
 
Thank you. That number "70107" is the PID (process ID) of the ntpd. With a running ntpd the number in /var/db/ntp/ntpd.pid should be the same as the PID you see when running ps (second column):
ntpd 70107 0.0 0.1 21864 6552 - Ss 19:54 0:00.02 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift

First, lets try something simple, see what happens. Please execute and show the output:
Code:
ps -auxww | grep ntpd
service -v ntpd stop
ps -auxww | grep ntpd
 
First, lets try something simple, see what happens. Please execute and show the output:
Code:
ps -auxww | grep ntpd
service -v ntpd stop
ps -auxww | grep ntpd
Again, you do want me to run all of these commands as root, correct? (Please always specify.)

Code:
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
ntpd       70107   0.0  0.1     21864   6552  -  Ss   19:54     0:00.13 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift
root       28275   0.0  0.0     12868   2440  1  S+   20:40     0:00.00 grep ntpd
root@<hostname>:/home/<username> # service -v ntpd stop
ntpd is located in /etc/rc.d
Stopping ntpd.
Waiting for PIDS: 70107.
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
root       31823   0.0  0.0     12868   2440  1  S+   20:41     0:00.00 grep ntpd
 
This looks and works as it is supposed to: promising. You had ntpd already running (from boot) and you succesfully stopped it via service

Next try these and with output, as root again:
Code:
ps -auxww | grep ntpd
service ntpd start
ps -auxww | grep ntpd
service ntpd status
service ntpd stop
ps -auxww | grep ntpd
service ntpd status
cat /var/db/ntp/ntpd.pid
 
Next try these and with output, as root again:
Code:
ps -auxww | grep ntpd
service ntpd start
ps -auxww | grep ntpd
service ntpd status
service ntpd stop
ps -auxww | grep ntpd
service ntpd status
cat /var/db/ntp/ntpd.pid
Code:
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
root       54877   0.0  0.0     12868   2440  1  S+   21:01     0:00.00 grep ntpd
root@<hostname>:/home/<username> # service ntpd start
Starting ntpd.
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
ntpd       63109   0.0  0.1     21864   6944  -  Ss   21:02     0:00.01 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift
root       64240   0.0  0.0     12868   2440  1  S+   21:02     0:00.00 grep ntpd
root@<hostname>:/home/<username> # service ntpd status
ntpd is running as pid 63109.
root@<hostname>:/home/<username> # service ntpd stop
Stopping ntpd.
Waiting for PIDS: 63109.
root@<hostname>:/home/<username> # ps -auxww | grep ntpd
root       71872   0.0  0.0     12868   2440  1  S+   21:03     0:00.00 grep ntpd
root@<hostname>:/home/<username> # service ntpd status
ntpd is not running.
root@<hostname>:/home/<username> # cat /var/db/ntp/ntpd.pid
63109root@<hostname>:/home/<username> #
 
Very nice, now it al seems to work as it should! I hope you can follow the things that happened along the command sequence you issued.

My guess it that somehow at some moment something went wrong with your /var/db/ntp/ntpd.pid.

What I know (this may not be the definitive answer):
When you have a runing ntpd (as observed via ps) after boot, you really need /var/db/ntp/ntpd.pid and the PID in the ps to be the same.

The service command is a general command that runs via another script. You might have seen examples of service xxx start where xxx is not ntpd. For ntpd (and I presume for all other daemons/services) it absolutely needs these two PIDs to be the same. When these two numbers are not the same service ntpd status wil not be able to find the running ntpd because it uses the number in ntpd.pid as an identification to locate ntpd by PID in all the running processes. It follows that service ntpd stop will also not work, obviously.

ntpd is a daemon process, briefly: that is a process that provides certain services in the background. Because of this nature they are usually started at boot time: that has to be specified of course. Before the introduction of the service command in FreeBSD daemons were started in another way. You have started the ntpd daemon manually, at least you tried to do so but were confronted with an already running ntpd: that generated the message unable to bind to wildcard address :: - another process may be running - EXITING in the log file (see also: ntpd(8)). You might agree that two instances of the same daemon (= two ntpd daemons with different PIDs) might not bode well for nice time keeping).

When you have a running ntpd (via ps) but service ntpd status says nothing is running, you probably have a problem that your /var/db/ntp/ntpd.pid does not have the same PID as the runnning ntpd. You can try to resolve that in the following manner (colors added for highlighting):

Rich (BB code):
% cat /var/db/ntp/ntpd.pid                                                                                       
37904
% ps -auxww | grep ntpd                                                                                                 
ntpd       47904   0.0  0.2   18860   6032  -  Ss   04:39      0:00.06 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -g
root       48330   0.0  0.1   11152   2208  3  R+   04:45      0:00.00 grep ntpd
% service ntpd status                                                                                                  
ntpd is not running.
% service ntpd stop                                                                                                     
ntpd not running? (check /var/db/ntp/ntpd.pid).
% rm /var/db/ntp/ntpd.pid                                                                                           
% echo 47904 > /var/db/ntp/ntpd.pid                                                                         
% cat /var/db/ntp/ntpd.pid                                                                                          
47904
% service ntpd status                                                                                                 
ntpd is running as pid 47904.
% service ntpd stop                                                                                                    
Stopping ntpd.
Waiting for PIDS: 47904.
% service ntpd status                                                                                                 
ntpd is not running.
%

What also works is that you can kill(1) the running ntpd and delete /var/db/ntp/ntpd.pid:
Rich (BB code):
% cat /var/db/ntp/ntpd.pid
38857
% ps -auxww | grep ntpd
ntpd       48857   0.0  0.2   18880   6036  -  Ss   04:51      0:00.09 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -g
root       49582   0.0  0.1   11176   2216  3  R+   05:02      0:00.00 grep ntpd
% service ntpd status
ntpd is not running.
% service ntpd stop
ntpd not running? (check /var/db/ntp/ntpd.pid).
% kill 48857
% rm /var/db/ntp/ntpd.pid
% ps -auxww | grep ntpd
root       49663   0.0  0.1   11268   2236  3  R+   05:03      0:00.00 grep ntpd
% service ntpd start
Starting ntpd.
% ps -auxww | grep ntpd
ntpd       49677   1.1  0.2   18764   6040  -  Ss   05:03      0:00.02 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -g
root       49679   0.0  0.1   11332   2244  3  S+   05:03      0:00.01 grep ntpd
% service ntpd status
ntpd is running as pid 49677.
% cat /var/db/ntp/ntpd.pid
49677% 
% service ntpd stop
Stopping ntpd.
Waiting for PIDS: 49677.
% service ntpd status
ntpd is not running.
% ps -auxww | grep ntpd
root       49768   0.0  0.1    4888   1988  3  R+   05:04      0:00.00 grep ntpd
%

Notice that, when starting ntpd, a new /var/db/ntp/ntpd.pid is created when it is not present.

___
Edit: For reference: Practical rc.d scripting in BSD
 
As far as I know starting ntpd via service is equivalent to manually starting via ntpd(8) as you did once (see above).

Now there is one more example that will show a "nice" log file when starting ntpd. As far as I know service does not provide a suitable possibility for the options that I have provided when starting ntpd manually (I did try but, also noticed that service(8) states as much).
Code:
% rm /var/log/ntp.log
% ps -auxww | grep ntpd
root       51998   0.0  0.1   11144   2184  3  R+   05:37      0:00.00 grep ntpd
% /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log
% ps -auxww | grep ntpd
root       52000   0.1  0.2   18800   6052  -  Ss   05:37      0:00.02 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log
root       52002   0.0  0.1   11332   2244  3  S+   05:37      0:00.00 grep ntpd
% service ntpd status
ntpd is running as pid 52000.
% ls -l /var/log/ntp.log
-rw-r--r--  1 root  wheel  2328 Dec  5 05:37 /var/log/ntp.log
% cat /var/log/ntp.log
 5 Dec 05:37:21 ntpd[51999]: ntpd 4.2.8p15-a (1): Starting
 5 Dec 05:37:21 ntpd[51999]: Command line: /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log
 5 Dec 05:37:21 ntpd[51999]: ----------------------------------------------------
 5 Dec 05:37:21 ntpd[51999]: ntp-4 is maintained by Network Time Foundation,
 5 Dec 05:37:21 ntpd[51999]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
 5 Dec 05:37:21 ntpd[51999]: corporation.  Support and training for ntp-4 are
 5 Dec 05:37:21 ntpd[51999]: available at https://www.nwtime.org/support
 5 Dec 05:37:21 ntpd[51999]: ----------------------------------------------------
 5 Dec 05:37:21 ntpd[52000]: proto: precision = 0.399 usec (-21)
 5 Dec 05:37:21 ntpd[52000]: basedate set to 2018-08-07
 5 Dec 05:37:21 ntpd[52000]: gps base set to 2018-08-12 (week 2014)
 5 Dec 05:37:21 ntpd[52000]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
 5 Dec 05:37:21 ntpd[52000]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2022-06-28T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
 5 Dec 05:37:21 ntpd[52000]: Listen and drop on 0 v6wildcard [::]:123
 5 Dec 05:37:21 ntpd[52000]: Listen and drop on 1 v4wildcard 0.0.0.0:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 2 lo0 [::1]:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 3 lo0 [fe80::1%2]:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 4 lo0 127.0.0.1:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 5 wlan0 192.168.178.18:123
 5 Dec 05:37:21 ntpd[52000]: Listening on routing socket on fd #26 for interface updates
 5 Dec 05:37:21 ntpd[52000]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
 5 Dec 05:37:21 ntpd[52000]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
 5 Dec 05:37:22 ntpd[52000]: Soliciting pool server 94.130.49.186
 5 Dec 05:37:23 ntpd[52000]: Soliciting pool server 206.82.28.3
 5 Dec 05:37:24 ntpd[52000]: Soliciting pool server 216.229.4.66
 5 Dec 05:37:25 ntpd[52000]: Soliciting pool server 192.36.143.130
 5 Dec 05:37:26 ntpd[52000]: Soliciting pool server 162.159.200.1
 5 Dec 05:37:27 ntpd[52000]: Soliciting pool server 162.159.200.123
 5 Dec 05:37:28 ntpd[52000]: Soliciting pool server 129.250.35.251
 5 Dec 05:37:29 ntpd[52000]: Soliciting pool server 185.51.192.34
% service ntpd stop
Stopping ntpd.
Waiting for PIDS: 52000.
% ps -auxww | grep ntpd
root       52108   0.0  0.1   11332   2244  3  S+   05:38      0:00.00 grep ntpd
% service ntpd status
ntpd is not running.
% cat /var/log/ntp.log
 5 Dec 05:37:21 ntpd[51999]: ntpd 4.2.8p15-a (1): Starting
 5 Dec 05:37:21 ntpd[51999]: Command line: /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift -D 1 -l /var/log/ntp.log
 5 Dec 05:37:21 ntpd[51999]: ----------------------------------------------------
 5 Dec 05:37:21 ntpd[51999]: ntp-4 is maintained by Network Time Foundation,
 5 Dec 05:37:21 ntpd[51999]: Inc. (NTF), a non-profit 501(c)(3) public-benefit
 5 Dec 05:37:21 ntpd[51999]: corporation.  Support and training for ntp-4 are
 5 Dec 05:37:21 ntpd[51999]: available at https://www.nwtime.org/support
 5 Dec 05:37:21 ntpd[51999]: ----------------------------------------------------
 5 Dec 05:37:21 ntpd[52000]: proto: precision = 0.399 usec (-21)
 5 Dec 05:37:21 ntpd[52000]: basedate set to 2018-08-07
 5 Dec 05:37:21 ntpd[52000]: gps base set to 2018-08-12 (week 2014)
 5 Dec 05:37:21 ntpd[52000]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): good hash signature
 5 Dec 05:37:21 ntpd[52000]: leapsecond file ('/var/db/ntpd.leap-seconds.list'): loaded, expire=2022-06-28T00:00:00Z last=2017-01-01T00:00:00Z ofs=37
 5 Dec 05:37:21 ntpd[52000]: Listen and drop on 0 v6wildcard [::]:123
 5 Dec 05:37:21 ntpd[52000]: Listen and drop on 1 v4wildcard 0.0.0.0:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 2 lo0 [::1]:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 3 lo0 [fe80::1%2]:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 4 lo0 127.0.0.1:123
 5 Dec 05:37:21 ntpd[52000]: Listen normally on 5 wlan0 192.168.178.18:123
 5 Dec 05:37:21 ntpd[52000]: Listening on routing socket on fd #26 for interface updates
 5 Dec 05:37:21 ntpd[52000]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
 5 Dec 05:37:21 ntpd[52000]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
 5 Dec 05:37:22 ntpd[52000]: Soliciting pool server 94.130.49.186
 5 Dec 05:37:23 ntpd[52000]: Soliciting pool server 206.82.28.3
 5 Dec 05:37:24 ntpd[52000]: Soliciting pool server 216.229.4.66
 5 Dec 05:37:25 ntpd[52000]: Soliciting pool server 192.36.143.130
 5 Dec 05:37:26 ntpd[52000]: Soliciting pool server 162.159.200.1
 5 Dec 05:37:27 ntpd[52000]: Soliciting pool server 162.159.200.123
 5 Dec 05:37:28 ntpd[52000]: Soliciting pool server 129.250.35.251
 5 Dec 05:37:29 ntpd[52000]: Soliciting pool server 185.51.192.34
 5 Dec 05:38:31 ntpd[52000]: ntpd exiting on signal 15 (Terminated)
 5 Dec 05:38:31 ntpd[52000]: 94.130.49.186 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 206.82.28.3 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 216.229.4.66 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 192.36.143.130 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 162.159.200.1 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 162.159.200.123 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 129.250.35.251 local addr 192.168.178.18 -> <null>
 5 Dec 05:38:31 ntpd[52000]: 185.51.192.34 local addr 192.168.178.18 -> <null>
%

Happy timekeeping :)
 
Thank you, Erichans. It sounds like you fixed it!

As mentioned elsewhere (probably in this thread), I am new to Unix and am not a computer scientist. When I first read your messages on my phone when I got up this morning, I didn't really understand them because my technical knowledge is limited. When I looked at them again on my computer, however, they started to make more sense (admittedly, I understand post #48 more than #49).

Some questions/observations:

1) Is it safe for me to run % service ntpd status (as a regular user) now to monitor the status of ntpd?

2) In your examples, it's my understanding when you're logged in as root your command prompt is "%," whereas on my computer that command prompt is reserved for a regular user.

3) I noticed one of the last things you had me do in my terminal, and in your examples in post #48, is run # service ntpd stop without running the equivalent command to start it afterwards. Was I not supposed to then start ntpd? Was it already started or started via another method? Is my ntpd already started?
 
Back
Top