#!/bin/bash # /usr/bin/nohup /root/tcp-watchdog.bash /dev/null & counter=0 while true; do if ping -c 1 -W 5 1.1.1.1 > /dev/null 2>&1; then counter=0 else ((counter++)) if [ "$counter" -gt 60 ]; then logger 'tcp-watchdog: failed for 30 minutes, rebooting...' reboot fi fi sleep 30 done