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.

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

ping -c 1 -w 3 8.8.8.8; echo $?

This also uses CRON to run script @reboot.

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

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

       if [ $PING -ne 0 ]; then
           echo "No connection"   
       else
         echo "Connected!"
       fi
done
EOF
chmod +x /srv/ping_check.sh

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



  • No labels