ntpsec-rs-wait — ntpwait-rs
NTP wait tool — blocks until an NTP server becomes reachable or a time condition is met.
Part of the ntpsec-rs workspace — a forensic Rust reconstruction of NTPsec. Version 0.3.48.
Overview
ntpwait-rs is a utility tool that blocks execution until an NTP server
becomes reachable or a time synchronization condition is satisfied. It is a
forensic Rust reconstruction of the NTPsec ntpwait Python client.
This tool is primarily used in boot scripts and deployment automation to ensure that time synchronization is established before starting time-sensitive services.
Use Cases
Boot Scripts
In system startup sequences, ntpwait-rs ensures the system clock is
synchronized before dependent services start:
#!/bin/sh
# Start NTP daemon
&
# Wait for synchronization
# Start time-sensitive services
Deployment Automation
In container orchestration or CI/CD pipelines, verify time sync before running distributed tests:
if [; then
else
fi
Configuration Management
As a precondition in Ansible, Puppet, or Chef playbooks:
- name: Wait for NTP sync
command: ntpwait-rs -t 120
register: ntp_result
Command-Line Flags
| Flag | Description | Default |
|---|---|---|
-t, --timeout <secs> |
Maximum wait time in seconds | 30 |
-p, --poll-interval <secs> |
How often to poll for sync status | 1 |
-v, --verbose |
Enable verbose output showing polling progress | false |
-c, --command <cmd> |
ntpq command to check synchronization status | rv 0 |
Exit Codes
| Code | Meaning |
|---|---|
0 |
NTP server is reachable / time condition met |
1 |
Timeout reached without synchronization |
2 |
Error (connection refused, protocol error, etc.) |
Usage Examples
Basic Wait (30-second default timeout)
Wait with Custom Timeout
Waits up to 120 seconds for NTP synchronization.
Verbose Mode
Shows periodic status updates while waiting:
ntpwait-rs v0.3.48 — NTP wait tool (Rust)
Waiting up to 60 seconds for NTP sync...
poll 1: not synchronized yet (stratum=16)
poll 2: not synchronized yet (stratum=16)
poll 3: synchronized (stratum=3, offset=0.000456s)
NTP synchronization achieved after 3 seconds.
Fast Polling
Polls every 5 seconds instead of the default 1 second.
Integration with systemd
[Unit]
Description=MyService - requires NTP sync
Requires=ntpd-rs.service
After=ntpd-rs.service
[Service]
Type=oneshot
ExecStartPre=/usr/bin/ntpwait-rs -t 60
ExecStart=/usr/bin/my-service
Related Crates
All crates in the ntpsec-rs workspace on crates.io:
| Crate | Description | crates.io |
|---|---|---|
| ntpsec-rs-core | Deterministic engine, wire codec, Mode 6, auth, refclocks, NTS | |
| ntpsec-rs-io | Real I/O layer (system clock, network, state store) | |
| ntpsec-rs | Umbrella facade crate | |
| ntpsec-rs-d | ntpd-rs — NTP daemon binary | |
| ntpsec-rs-query | ntpq-rs — Mode 6 query client | |
| ntpsec-rs-dig | ntpdig-rs — NTP query tool | |
| ntpsec-rs-keygen | NTP key generation | |
| ntpsec-rs-leapfetch | Leap second file fetcher | |
| ntpsec-rs-mon | Real-time NTP monitoring tool | |
| ntpsec-rs-trace | NTP path trace tool | |
| ntpsec-rs-wait | Wait until NTP server reachable | |
| ntpsec-rs-viz | NTP data visualization | |
| ntpsec-rs-frob | NTP configuration manipulator | |
| ntpsec-rs-snmpd | SNMP monitoring daemon | |
| ntpsec-rs-time | Single-shot time query tool | |
| ntpsec-rs-sweep | Sweep through servers collecting stats | |
| ntpsec-rs-loggps | GPS reference clock logging | |
| ntpsec-rs-logtemp | System temperature logging |