Mittwoch, 4. Februar 2009

Check network connection

- create a file check_network.sh

#!/bin/bash
x=`ping -c1 google.com 2>&1 | grep unknown`
if [ ! "$x" = "" ]; then
echo "It's down!! Attempting to restart."
/etc/init.d/networking restart
echo "restarted gurke" | mail -s gurke_restart test@hotmail.com
fi



- chmod 777 check_network.sh
- add it to crontab so it checks it for every hour or so..

2 Kommentare:

rob hat gesagt…

Why would you be loosing network connection all the time?

Linus und Annamengia hat gesagt…

ask cablecom, they are cutting me off once in a while (renewing the IP)