Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

This setup allows continuous pinging of an IP and then takes action based on the outcome. Tweak times to desired times, I like to start with low times and test/watch it work, then modify actions, then increase time once I'm happy it's working.

Note: This uses the following command to write the output of the ping command to a file in the tmp dir. 

A result of 0 = Ping Response and 1 = Fail.

ping -c 1 -w 3; echo $?

This also uses CRON to run script @reboot.

cat << 'EOF' >/srv/
while :; do
   sleep 30 

       ping -c 1 -w 3 > /dev/null    
       PING=$(echo $?)

       if [ $PING -ne 0 ]; then
           echo "No connection" 
           echo "Connected!"
chmod +x /srv/

cat << 'EOF' >/etc/cron.d/ping_loop
@reboot root /srv/
chmod +x /etc/cron.d/ping_loop

  • No labels