openntpd – immediately sync the clock on startup

Here is our simple tip for your healthy server’s date and time:

Immediately synchronize the clock of your computer when using the openntpd (a lightweight version of ntpd with client-only mode).

Use the “-s” (lower “s” letter) to instruct the daemon ntpd to synchronize the clock immediately after it discovers a healthy time server!

-s          Try to set the time immediately at startup, as opposed to slowly adjusting the clock.  ntpd will stay in the foreground for up to 15 seconds waiting
                 for one of the configured NTP servers to reply.

Find the start-up configuration file in your “/etc” (for your Linux distribution, its name is probably ntpd, for Gentoo it is “/etc/conf.d/ntpd”, the thing is to find the start-up confiuration script, not the ntpd.conf, which is the ntpd configuration file for the daemon) and include “-s” in the NTPD_OPTS:

cat /etc/conf.d/ntpd 
# /etc/conf.d/ntpd: config file for openntpd's ntpd


Restart the service.

If you use it in a virtualized environment like containers (docker, lxc, lxd and so on) and qemu, virtualbox, vmware and so on and you often suspend the machine to synchronize the clock when you resume it you must manually restart the openntpd service!!! Or you are going to wait for slowly adjusting the time as usual.

Information status

There is a utility to check what’s going on with the openntpd – ntpctl. It has only three read-only commands:

usage: ntpctl -s all | peers | Sensors | status

Here is the output of “all” option (you should be root):

local ~ # ntpctl -s all
16/20 peers valid, clock synced, stratum 2

   wt tl st  next  poll          offset       delay      jitter from pool
    1 10  2   14s   32s        -0.512ms     5.184ms     0.287ms from pool
    1 10  3   18s   30s         0.033ms     1.880ms     0.548ms from pool
    1 10  2    9s   32s        -1.635ms     8.085ms     0.070ms from pool
    1 10  2   14s   30s         2.922ms     3.936ms     0.279ms from pool
    1 10  2   12s   34s         0.979ms     3.447ms     0.239ms from pool
    1 10  2   11s   33s        -0.339ms     5.087ms     0.290ms from pool
    1 10  2   14s   31s         1.658ms    13.987ms     0.229ms from pool
    1 10  2   21s   34s        -0.442ms     3.770ms     0.366ms
2a0b:f800:0:1::101 from pool
    1  2  -    6s   15s             ---- peer not valid ----
2001:67c:20d0:c0::acad:123 from pool
    1  2  -    6s   15s             ---- peer not valid ----
2a02:6800:0:99::2 from pool
    1  2  -    6s   15s             ---- peer not valid ----
2001:67c:21bc:1e::1:123 from pool
    1  2  -    6s   15s             ---- peer not valid ---- from pool
    1 10  1   11s   31s         0.169ms     4.216ms     0.156ms from pool
 *  1 10  1    0s   32s        -0.456ms     3.898ms     0.256ms from pool
    1 10  3    3s   33s         1.667ms     3.976ms     0.246ms from pool
    1 10  2   16s   30s         5.331ms     3.789ms     0.225ms from pool
    1 10  3    4s   34s        -2.058ms    14.554ms     0.374ms from pool
    1 10  2    3s   32s        -1.497ms     3.726ms     0.233ms from pool
    1 10  3    0s   34s        -5.923ms     4.309ms     0.905ms from pool
    1 10  2    2s   33s        -2.942ms    11.703ms     0.345ms

Leave a Reply

Your email address will not be published. Required fields are marked *