FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

12739 questions

15125 answers

24287 comments

47347 members

0 votes
125 views 1 comments
by

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

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
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.