#!/bin/bash # (/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 10 minutes, restart networking...' #reboot service networking restart fi fi sleep 10 done