0

I'm running Ubuntu 14.04 on an Nvidia Jetson TX1. For some reason the clock is not staying synchronized properly, and the simplest solution seems to me to use upstart to call ntpdate on a regular basis (I know upstart better than cron).

Here is my .conf file:

description "Refresh date every 30 seconds"

start on (started networking)

respawn

script
        echo "Starting script..."
        exec service ntp stop
        echo "sleeping."
        exec sleep 60
        echo "Contacting time.nist.gov..."
        exec ntpdate -v time.nist.gov
        echo "...done. Restarting service."
        exec service ntp start
end script

post-stop exec sleep 5

(The sleep step and echo's were added for debugging).

If I tail the output, I get

Starting script...
 * Stopping NTP server ntpd                                              [ OK ]
Starting script...
 * Stopping NTP server ntpd                                              [ OK ]
Starting script...
 * Stopping NTP server ntpd                                              [ OK ]
Starting script...
 * Stopping NTP server ntpd                                              [ OK ]

which updates every 5 seconds. The ntp service does stop, but it seems like something there kills the upstart job, triggers the post-stop script, and then the job respawns.

Why is my job quitting early?

Edit 8/30/2017 @user731091 caught a typo of npt instead of ntp. I've updated my original code with the typo fix, but the log output is still the same.

1

I think the problem is a typo in your start command:

exec service npt start

should be:

exec service ntp start
  • Wow that was a good find. Doesn't solve the problem unfortunately - the log output is the same as in my original post after making the change. The problem seems like it should be in the ntp stop command, since "sleeping" is never printed. – RedPanda Aug 30 '17 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.