#!/bin/bash lastcond="0" while [ true ] do echo "$lastping" # Edit this setting to your server ip ping -c 1 192.168.178.7 lastping1="$?" ping -c 1 192.168.178.8 lastping2="$?" ping -c 1 192.168.178.3 lastping3="$?" nodesonline=$((4-$lastping1-$lastping2-$lastping3)) if [ "$lastcond" != "$nodesonline" ] then pvecm expected $nodesonline lastcond=$nodesonline fi #echo $nodesonline sleep 15 done