ntpsec-rs-wait 0.3.49

NTP wait tool — forensic Rust reconstruction of ntpwait
ntpsec-rs-wait-0.3.49 is not a library.

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
ntpd-rs -n &
# Wait for synchronization
ntpwait-rs -t 60
# Start time-sensitive services
postgresql start

Deployment Automation

In container orchestration or CI/CD pipelines, verify time sync before running distributed tests:

ntpwait-rs -t 300 -v
if [ $? -eq 0 ]; then
    echo "Time is synchronized. Proceeding with deployment..."
    deploy
else
    echo "WARNING: NTP did not synchronize within timeout."
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)

ntpwait-rs

Wait with Custom Timeout

ntpwait-rs -t 120

Waits up to 120 seconds for NTP synchronization.

Verbose Mode

ntpwait-rs -v -t 60

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

ntpwait-rs -p 5 -t 30

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 crates.io
ntpsec-rs-io Real I/O layer (system clock, network, state store) crates.io
ntpsec-rs Umbrella facade crate crates.io
ntpsec-rs-d ntpd-rs — NTP daemon binary crates.io
ntpsec-rs-query ntpq-rs — Mode 6 query client crates.io
ntpsec-rs-dig ntpdig-rs — NTP query tool crates.io
ntpsec-rs-keygen NTP key generation crates.io
ntpsec-rs-leapfetch Leap second file fetcher crates.io
ntpsec-rs-mon Real-time NTP monitoring tool crates.io
ntpsec-rs-trace NTP path trace tool crates.io
ntpsec-rs-wait Wait until NTP server reachable crates.io
ntpsec-rs-viz NTP data visualization crates.io
ntpsec-rs-frob NTP configuration manipulator crates.io
ntpsec-rs-snmpd SNMP monitoring daemon crates.io
ntpsec-rs-time Single-shot time query tool crates.io
ntpsec-rs-sweep Sweep through servers collecting stats crates.io
ntpsec-rs-loggps GPS reference clock logging crates.io
ntpsec-rs-logtemp System temperature logging crates.io

GitHub Repository

https://github.com/infinityabundance/ntpsec-rs