You are not logged in.

#1 2011-01-05 16:41:41

brenix
Member
From: California
Registered: 2008-03-05
Posts: 185

[SOLVED] Script or Daemon to reboot if internet down?

After a recent cable modem upgrade, my arch box appears to lose connectivity while I am working on it remotely. If I reboot it, it re-establishes the connection and starts working again..

Since this seems to happen while I am working remotely, it becomes very frustrating because I cannot troubleshoot it until I get home. I was curious if anyone knew or had a script or daemon that frequently checks for internet connectivity. If it doesn't have connectivity, then reboots the system or restarts networking.. This would be helpful so I could at least remotely connect and determine what is causing the issue..

Anyone?

EDIT: I guess this is pretty simple to run a cron job to check connectivity via a script and reboot if connectivity is lost..Here's what I got so far.. Anyone have anything else??

#!/bin/bash
WGET="/usr/bin/wget"

$WGET -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null

if [ ! -s /tmp/index.google ];then 
        reboot
else 
        echo "connection working.." 
fi

Last edited by brenix (2011-01-05 19:35:10)

Offline

#2 2011-01-05 17:31:01

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: [SOLVED] Script or Daemon to reboot if internet down?

instead of rebooting, cant you just bring the interface down and up again?

how is your network set up?

/etc/rc.d/network restart should do it.

/etc/rc.d/net-auto-wired restart would work too wink

Offline

#3 2011-01-05 17:50:24

BaconPie
Member
Registered: 2010-08-11
Posts: 209

Re: [SOLVED] Script or Daemon to reboot if internet down?

eldragon wrote:

instead of rebooting, cant you just bring the interface down and up again?

He can't deal with anything on the computer if he is remotely logged in and then the network goes down.

Instead of downloading google with wget why not just ping it three times (ping -c 3 www.google.com). If the ping fails then reboot. Put it in a script and run it from a cron job every 5 mins.

Offline

#4 2011-01-05 19:36:43

brenix
Member
From: California
Registered: 2008-03-05
Posts: 185

Re: [SOLVED] Script or Daemon to reboot if internet down?

thats what I had done is have it just ping instead. Thanks for the tips..

Oddly enough it appears the network is stable now too.. good to have in case it comes back..

Offline

#5 2011-01-05 20:33:05

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: [SOLVED] Script or Daemon to reboot if internet down?

i meant for him to have the cronjob bring the interface down and up again.

Offline

Board footer

Powered by FluxBB