Linino date/time

Hello,
After power up, it takes a while for Linino to boot, connect to wifi and then make the first connection to the NTP server to get the current date/time. During this period, the date/time that the Linino reports is wrong.
Is there a way to figure out from an Arduino sketch when the first NTP server update has been completed successfully ?

Thanks!

nano  /mnt/sda1/ntpd.sh
#!/bin/sh
SERVICE="/usr/sbin/ntpd"
ps |grep -v grep | grep $SERVICE > /dev/null
result=$?
echo "exit code: ${result}"
if [ "${result}" -eq "0" ] ; then
    echo "`date`: $SERVICE service running, everything is fine"
else
    echo "`date`: $SERVICE is not running"
fi
chmod 755  /mnt/sda1/ntpd.sh

Use bridge read result code.

Thanks for the suggestion.

However, just because the ntpd process is running it doesn't mean that the Linino date/time has been updated from NTP server successfully....

busybox-ntpd which installed by default at linino doesn't support advanced features like query. We need update it to standard package of ntpd.

opkg update
opkg install ntpd
opkg install ntp-utils
/etc/init.d/sysntpd disable
/etc/init.d/ntpd enable
/etc/init.d/ntpd start
ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp2.h.vporn.co 173.13.85.5      2 u   65   64   37   57.814   -9.849   2.276
+host2.kingrst.c 208.75.88.4      3 u   61   64   37   40.626   -6.173   5.317
-services.quadra 121.130.110.69   3 u   61   64   37   81.499   -1.507   3.616
*repos.lax-noc.c 216.218.254.202  2 u   68   64   37   79.674   -2.960   3.111

Use bridge read result code of 'ntpq -p'.

Sounds good, I'll try it.
Thank you very much !

Just FYI, I found a solution via the "ping" command. If I can ping the NTP servers then I'm assuming that the date/time are set correctly. It is still possible that there is some lag between the first successful ping and the moment the ntpd process sets the date/time correctly but it's usually just a few seconds and I'm willing to live with that.

For example :

import re
import subprocess
import time

def getDayTime(format):
    s = subprocess.Popen(["ping", "-c", "1", "-q", "0.openwrt.pool.ntp.org"], stdout = subprocess.PIPE)
    for x in s.stdout:
        if re.search("0% packet loss", x):
            return time.strftime(format)
            
    return ""