LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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-11-2008, 11:04 PM   #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, 04:11 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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, 08: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-12-2008, 11:50 PM   #4
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Use ifplugd.
 
  


Reply

Tags
connection, monitor, wifi



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:21 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration