#1137431 ntpsec: ntpwait fails immediately if ntpsec service has not yet started

Package:
ntpsec
Source:
ntpsec
Description:
Network Time Protocol daemon and utility programs
Submitter:
Aaron Bugher
Date:
2026-08-23 21:15:02 UTC
Severity:
normal
#1137431#5
Date:
2026-05-23 18:57:01 UTC
From:
To:
Dear Maintainer,

This may be considered either a bug in functionality or a bug in the documentation.  `man ntpwait` says, "The ntpwait program blocks until ntpd is in synchronized state."  That is only true if the ntpsec service is already running.

I have a cron job that runs at boot time and should wait for NTP synchronization.  Apparently the cron service can start before the ntpsec service, so using ntpwait in the script causes immediate failure instead of waiting for ntpd (ntpsec) to start and synchronize.

Example:


ansible@neuron-mail:~$ sudo systemctl stop ntpsec
ansible@neuron-mail:~$ # This fails immediately.
ansible@neuron-mail:~$ ntpwait
localhost: timed out, nothing received
***Socket error; probably ntpd is not running
Leap status not available
ansible@neuron-mail:~$ echo $?
1
ansible@neuron-mail:~$ sudo systemctl start ntpsec
ansible@neuron-mail:~$ # This works as expected.
ansible@neuron-mail:~$ ntpwait
ansible@neuron-mail:~$ echo $?
0
ansible@neuron-mail:~$

#1137431#10
Date:
2026-08-23 21:02:24 UTC
From:
To:
I'll forward this upstream to see what they think about the intended
behavior.


I recommend you do the following:

1. Change your task from cron to a systemd .service / .timer pair. In
your .service, have:

[Unit]
Requires=time-sync.target
After=time-sync.target

2. Enable ntpsec-wait.service


ntp-wait.service is ordered After=ntpsec.service and
Before=time-sync.target. Since your service will be
After=time-sync.target, it will not start until ntp-wait.service has
completed.

time-sync.target is a systemd standard thing. This indirection allows
other services to express that they want the time synchronized without
having to know which implementation is in use.