FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
194 views 1 comments
by anonymous

Hi,
I am using this command to check if NTP is working: ntpclient -h 0.europe.pool.ntp.org -c 1 
I noted that this command returns the result in a row but does not exit and the shell is hanged till press CTRL+C.
Is there a way to make the command exit automatically after the execution? For example, if I would use it in a script.

Thanks,
M

1 Answer

0 votes
by anonymous

Hello,

Unfortunately, this command requires CTRL+C to close it and you cant change it.

For example, if you would like to use it in the script you can get creative with it. One example I have found in forums:

# Launch script in background
./my_script_that_includes_command.sh &
# Get its PID
PID=$!
# Wait for 2 seconds
sleep 2
# Kill it
kill $PID

Regards.
Best answer
by anonymous
Note that this appears to be fixed in the RUT9XX firmware (tested with `RUT9_R_00.07.01.1`). `ntpclient -h x.x.x.x -c 1` performs a single probe and exits (`-g` seems to work as well). Really happy to see this after spending much of the day looking for options; having the ability to wait for an NTP sync resolves a long standing issue I have had with the RUTs.