LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-12-2008, 12:04 AM   #1
benoitcsirois
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:
Code:
/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?

Thanks!

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

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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
Code:
ping -c1 IP.OF.YOUR.ROUTER | grep "0 received"
when your router is connecting and
Code:
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, 09:24 PM   #3
benoitcsirois
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/pingtest.sh

Code:
ping -c 1 -w 5 "google.com" &>/dev/null
if [ $? -ne 0 ] ; then
    /etc/init.d/networking restart
fi
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.

Peace!
 
Old 01-13-2008, 12:50 AM   #4
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Use ifplugd.
 
  


Reply

Tags
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 06:57 AM
Monitor doesn't get active again after some time of inactiviy robbbert Linux - Hardware 0 06-24-2006 04:43 PM
pcmcia wifi card - installed: yes, active: no! evilhomer Suse/Novell 1 12-01-2004 07:57 PM
switching from monitor to tv out with no XFree restart? Gildas Linux - Hardware 3 05-26-2004 12:48 AM
Monitor and Restart - Bkg Processes? KendersPlace Linux - General 1 02-15-2003 03:27 AM


All times are GMT -5. The time now is 07:46 PM.

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