Server Fault Asked by ZioByte on November 27, 2021
I need to know if current date/time is reliable in a small embedded Linux system Busybox-based.
I have Busybox ntpd running, but apparently there is no program to to query status.
On a more conventional Linux installation I would use ntpdc, ntpq, ntpstat or even timedatectl, but none of these is available on this Busybox/Buildroot system.
What else can I do?
BusyBox does not provide the IPC/RPC interfaces that are needed to query the status of a running BusyBox NTP daemon, so even if you install one of the mentioned query utilities they will not be able to talk to BusyBox ntpd
.
Running ntpd -w
as mentioned in another answer will simply start another BusyBox ntpd
instance from scratch and this new one will not talk to an already running ntpd
process.
There is however another way to get status information from BusyBox ntpd
, by using its program/script interface. See the -S flag:
~# ntpd --help
BusyBox v1.30.1 () multi-call binary.
Usage: ntpd [-dnqNwl] [-I IFACE] [-S PROG] [-p PEER]...
NTP client/server
-d Verbose (may be repeated)
-n Do not daemonize
-q Quit after clock is set
-N Run at high priority
-w Do not set time (only query peers), implies -n
-S PROG Run PROG after stepping time, stratum change, and every 11 min
-p PEER Obtain time from PEER (may be repeated)
-l Also run as server on port 123
-I IFACE Bind server to IFACE, implies -l
The specified program will be executed regularly depending on different time events and NTP information is supplied as args to the program and in its environment. I find no info about this interface so the source code seems to be the docs in this case:
https://git.busybox.net/busybox/tree/networking/ntpd.c
Look up the function run_script()
and you can see that it calls the external program with action
as argument and stratum
, freq_drift_ppm
, poll_interval
and offset
as environment variables.
Chances are that your embedded Linux distro is already hooking into this interface. On my OpenWrt box ntpd
is running with this command line:
/usr/sbin/ntpd -n -N -S /usr/sbin/ntpd-hotplug -p 0.openwrt.pool.ntp.org -p 1.openwrt.pool.ntp.org -p 2.openwrt.pool.ntp.org -p 3.openwrt.pool.ntp.org
and as you can see the program interface is hooking into OpenWrt's procd hotplug support. In OpenWrt this means that you instead add your NTP scripts to /etc/hotplug.d/ntp
but the information supplied to your script is still the same, see NTP section here:
Answered by mikewse on November 27, 2021
ntpd -w
will provide some information, such as what the current offset is from your NTP servers.
Answered by Russ on November 27, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP