Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-11-2008, 11:04 PM   #1
LQ Newbie
Registered: Jan 2008
Location: Montreal
Distribution: fluxbuntu
Posts: 5

Rep: Reputation: 0
Smile Wifi connection monitor / restart if not active

Hi, I am running a home server.. just for fun, and the Wifi connection is not so stable so when I get to work and try to login my "box", it's usually offline. (I know it's offline because iwconfig no longer shows that it's connected)

When I get disconnected, I just need to:
/etc/init.d/networking restart
What simple piece of software can monitor my connection and run that command if it disconnects again? Can it monitor iwconfig?


Old 01-12-2008, 04:11 AM   #2
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
You could set up a cron job that would ping your router every 5mins or so. If it doesn't receive a reply, then it should call /etc/init.d/networking restart

Hint: Look at the outputs of
ping -c1 IP.OF.YOUR.ROUTER | grep "0 received"
when your router is connecting and
ping -c1 IP.NOTON.YOUR.NETWORK | grep "0 received"
One returns nothing, the other some text. So you could do a test on the result, and then call /etc/init.d/networking restart if needed.

Have fun, and Welcome to LQ!
Old 01-12-2008, 08:24 PM   #3
LQ Newbie
Registered: Jan 2008
Location: Montreal
Distribution: fluxbuntu
Posts: 5

Original Poster
Rep: Reputation: 0
Cool My solution

Well I suck at scripting, but while browsing around, I found a short script that tests the connection with google (using ping)... i just modified it a bit for my own purpose. Here it is in case it can help anyone else:

I called it /sbin/

ping -c 1 -w 5 "" &>/dev/null
if [ $? -ne 0 ] ; then
    /etc/init.d/networking restart
And I placed an entry in crontab that launches this script every 2 minutes.

I would prefer a small script that actually checks whether or not the Wifi card has established a connection but that's more of a pain in the butt, so this does it for now.

Old 01-12-2008, 11:50 PM   #4
LQ Guru
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Use ifplugd.


connection, monitor, wifi

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to restart wifi card? banz Linux - Wireless Networking 1 01-19-2007 05:57 AM
Monitor doesn't get active again after some time of inactiviy robbbert Linux - Hardware 0 06-24-2006 03:43 PM
pcmcia wifi card - installed: yes, active: no! evilhomer SUSE / openSUSE 1 12-01-2004 06:57 PM
switching from monitor to tv out with no XFree restart? Gildas Linux - Hardware 3 05-25-2004 11:48 PM
Monitor and Restart - Bkg Processes? KendersPlace Linux - General 1 02-15-2003 02:27 AM

All times are GMT -5. The time now is 03:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration