Re: init.d script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 7, 2004 08:54 am, Greg Bradner wrote:
> Within an init.d startup script, I would like to check if a host is up
> before continuing.
> ex:
> in the ntpd script, if ntp.server.com is not pingable, exit - instead of
> waiting for the long timeout period.
>
> Any suggestions?
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gregb@xxxxxxxxxx

Hi,
there are a few things to consider. 
-how many ping attempts before it fails
-can the server be ping'd
-you may want to consider using traceroute to the NTP port 525(?)

Here is andea for the basic ping part:
#!/bin/bash
TARGET="$1"
TEST_RESULTS="/tmp/alive_test.txt"

if [ -z "$TARGET" ] ; then
  echo "usage: alive.sh host.domain.com"
  exit
fi
 
rm -rf $TEST_RESULTS
ping -c 3 $TARGET|grep "64 bytes" > $TEST_RESULTS

 if [ -s "$TEST_RESULTS" ] ; then
   echo "`cat $TEST_RESULTS`" # <-put your init script here
 else
   echo "Server is not available. Script failed"
 fi
#end if script

This is not very refined or tested except for basic functionality

Hope that helps
-- 
Pete Nesbitt, rhce


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux