Create a bash script as root:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#!/bin/bash sleep 300 while true do /usr/bin/wget –q —spider http://google.com if [ ! $? –eq 0 ]; then echo “Network unreachable, rebooting. Time: `date`” >> /var/log/network_reboot.log /usr/sbin/reboot fi sleep 60 done |
I saved it to /root/check_network.sh and did a
|
1 |
chmod +x check_network.sh |
to it.
Then I opened the crontab as root with
|
1 |
crontab –e |
and added at the end the following line
|
1 |
@reboot /root/check_network.sh |
