I'm trying to use NTPD to update my Linux machine's time to a specified NTP server.
Here is the scenario:
Each time the Linux machine starts up, I want to update the time from NTP server and if it's not successful, I want to try again every 5 minutes until successfully (max is 2 hours).
I searched around and find that I should(?) use NTPD and use some command like:
#ntpdate ntp.server.com
(before starting NTPD)
#ntpd some_options_to_start
The questions are:
- How can I know if the time was successfully updated by these commands?
- Can I set the interval to update time from ntpd? (or I have to use something like
sleep
and loop withdo
..while
/for
in shell?)
Note that I want to execute the above commands in a shell script and will put the shell in a web server. Then clients (with a web browser browser) will execute the script on the website. So I need to check if the update is successful or not to send result to the client (over the web).