johnofleek / legatoNtp

A way of setting system time via ntpd when the cellular network is available
MIT License
0 stars 0 forks source link

The system call causes a new ntpd to start and it looks as if it can return but the shell is blocked #1

Open johnofleek opened 6 years ago

johnofleek commented 6 years ago

FX30 16.10.1 system("/usr/sbin/ntpd -p time.nist.gov"); If the ntpd fails the system function returns with an ntpd running in another process?

johnofleek commented 6 years ago

You've been bitten by busybox again.

    -d      Verbose
    -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
    -l      Run as server on port 123
    -S PROG Run PROG after stepping time, stratum change, and every 11 mins
    -p PEER Obtain time from PEER (may be repeated)

ntpd automatically daemonizes (into the background) when run. So each time you called it because it looked like the system() call failed, another copy of the ntpd daemon was created and started....

You also need to add the -n (and perhaps -q) options to the command line as well to stop ntpd daemonizing (and potentially make sure it dies after setting the time).

Also, have a look at pool.ntp.org ... it's a free to use collection of round robin ntp servers around the world - dns helps you to find one 'close' to you.

Ntp is on port 123.

Also - Have a look at the file /etc/time_service.conf and uncomment the line TIME_SERVICES="qcom_time ntpd_time" (and comment comment any other TIME_SERVICES lines...).