On 2007-04-23, Nigel Henry <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
NTP Public Services Project - http://ntp.isc.org/

_______________________________________________
questions mailing list
[email protected]
https://lists.ntp.isc.org/mailman/listinfo/questions

Reply via email to