rc.conf "ntpd_sync_on_start" confused -g and -q?

Hello!

I set my machine to synchronize the clock when the machine boots up. Ntpdate would do the trick. Quote from ntpdate man page:

"Note: The functionality of this program is now available in the ntpd(8) program. See the -q command line option in the ntpd(8) page. After a suitable period of mourning, the ntpdate utility is to be retired from this distribution."

So I chose to use ntpd instead of ntpdate.

Starting ntpd with option -q does seem to do what ntpdate would do.

From ntpd man page:

"-q
Exit the ntpd just after the first time the clock is set. This behavior mimics that of the ntpdate(8) program, which is to be retired. The -g and -x options can be used with this option. Note: The kernel time discipline is disabled with this option."

However, seems like rc.conf man page would have mixed -g and -q.

From rc.conf man page:
"ntpd_sync_on_start

(bool) If set to ``YES'', ntpd(8) is run with the -g flag, which syncs the system's clock on startup. See ntpd(8) for more information regarding the -g option. This is a preferred alternative to using ntpdate(8) or specifying the ntpdate_enable variable."


From ntd man page:

"-g
Normally, ntpd exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows thetime to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that, ntpd will exit with a message to the system log. This option can be used with the -q and -x options. See the tinker command for other options."

So I tested rc.conf with "ntpd_sync_on_start" and it indeed started ntpd with "-g" option.
Then I replaced that with "ntpd_flags="-g -q -x" and got what I wanted, only one run of ntpd at boot time, then ntpd exits.

Have I misunderstood something here, or is there little confusion between g and q in rc.conf "ntpd_sync_on_start" option?

:q
 
put the following lines to /etc/rc.conf

Code:
ntpdate_enable="YES"             # Run ntpdate to sync time on boot (or NO).
ntpdate_hosts="some.ntp.server"  # Whitespace-separated list of ntpdate(8) servers.

That should be just fine and work at least another decade... :)


And indeed, what you have described in your post seems a bit confusing. I will try to have a look at it later...
 
So what you have described seems really like a bug in our rc.d system. Could you have a look at this patch made by Giorgos Keramidas (aka. keramida@) and see whether it clears out your confusion?

I suppose it will be committed to our source tree pretty soon. Nice catch and thanks for reporting the issue!
 
Back
Top