[ntp:questions] Local clock question with dialup connection

Steve Kostecke kostecke at ntp.isc.org
Mon Apr 23 20:20:31 UTC 2007


On 2007-04-23, Nigel Henry <cave.dnb at tiscali.fr> wrote:

> The script needs to ping some server on the Internet. If it receives no 
> response, and exits with a code 1, it will then sleep for 60 secs, then run 
> the ping again, and so on. When an Internet connection is eventually 
> established, and that is if I understand this correctly, ping will then exit 
> with a code 0.
>
> Once a code 0 is received, showing the host to be alive, no further pings 
> should be sent, and the script at /usr/local/bin/ntp-restart will be run.

Here's one way to do this. Handling situations such as when this script
does not exit or more than one copy of this script is started are left
as an excercise...

#!/bin/sh

# The hostname or IP address of the host that you want to ping.
TARGET=

while [ 1 ]
do
  /bin/ping -c 4 $TARGET 2>/dev/null >/dev/null && break
  /bin/sleep 60
done

/usr/local/bin/ntp-restart

-- 
Steve Kostecke <kostecke at ntp.isc.org>
NTP Public Services Project - http://ntp.isc.org/




More information about the questions mailing list