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 BusyBoxntpd
instance from scratch and this new one will not talk to an already runningntpd
process.There is however another way to get status information from BusyBox
ntpd
, by using its program/script interface. See the -S flag: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 withaction
as argument andstratum
,freq_drift_ppm
,poll_interval
andoffset
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: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:https://openwrt.org/docs/guide-user/base-system/hotplug
ntpd -w
will provide some information, such as what the current offset is from your NTP servers.