LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-21-2004, 04:20 PM   #1
mac_phil
Member
 
Registered: Sep 2003
Distribution: Mandrake 10.0
Posts: 200

Rep: Reputation: 30
Cron job to check/restart network connection?


I leave my computer running nonstop. Every few months it loses its connection. I get my IP through DHCP and have no control over the DHCP server. My IP never changes even though it is dynamic.

I would like to do something to ensure that the computer puts itself back online.

Would a cron job be a good idea? I could have it check the network status every hour, and do a 'service network restart' (or equivalent) if it is offline.

Could you tell me if this is the correct solution, and if so, exactly what commands would I put in the cron job?

When the machine is offline doing 'service network status' returns: configured currently active lo eth0.

Thanks.
 
Old 06-22-2004, 12:36 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I'm sure that you could create a script to check the output from somthign like:
ping -c 3 ip.of.your.gateway | grep -c "bytes from"

If the outut is 3 then the connection is OK - 0 then the system cannot reach your gateway and in the middle if there are intermittent network problems.

Although your IP is assigned by DHCP - have you tried configuring for a static IP (using the same details that DHCP gives)?
 
Old 07-07-2004, 07:24 PM   #3
mac_phil
Member
 
Registered: Sep 2003
Distribution: Mandrake 10.0
Posts: 200

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by david_ross
I'm sure that you could create a script to check the output from somthign like:
ping -c 3 ip.of.your.gateway | grep -c "bytes from"

If the outut is 3 then the connection is OK - 0 then the system cannot reach your gateway and in the middle if there are intermittent network problems.

Although your IP is assigned by DHCP - have you tried configuring for a static IP (using the same details that DHCP gives)?
Interesting, thanks. Is "service network restart" the right command for getting the connection back? I'll start writing a script.

I'm not quite sure what you mean configuring for a static IP. What benefits would that offer?

PS - Sorry for the late reply, I was gone fishin' as they say.
 
Old 07-08-2004, 12:47 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
"service network restart" should reset the connection for you.

If your IP never changes then you may be able to just specify the IP, netmask and gateway - this should solve the problem if it is a dhcp issue.
 
Old 07-21-2004, 09:32 AM   #5
perry
Member
 
Registered: Sep 2003
Location: USA & Canada
Distribution: Slackware 12.0
Posts: 978

Rep: Reputation: 30
Quote:
Originally posted by david_ross
"service network restart" should reset the connection for you.

If your IP never changes then you may be able to just specify the IP, netmask and gateway - this should solve the problem if it is a dhcp issue.
thats funny.... i just installed slackware 10 and i'm using the 2.4.26 kernal and under mandrake i could always go "service network restart" if i needed to, however i just tried to use it here and it didn't know what i was talking about.

is "service network restart" a linux thing or a mandrake thing? having to reboot my linux system to get on the internet is NOT cool....

- perry
 
Old 07-21-2004, 10:41 AM   #6
comprookie2000
Gentoo Developer
 
Registered: Feb 2004
Location: Fort Lauderdale FL.
Distribution: Gentoo
Posts: 3,291
Blog Entries: 5

Rep: Reputation: 58
With Slackware I use dhcpcd eth0 because I lose mine also.
 
Old 09-01-2004, 01:51 PM   #7
mcostello1
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Rep: Reputation: 0
Hey I'm running into the same problem but we have a unique instance where as the linux server (RedHat) is running as a Microsoft Virtual Server. Is there anyway you can post the shell script.
I am unable to ping the box yet doing "service network restart" successfully shuts down the network interface and brings them back up and everything seems towork fine again for awhile. (Any Suggestions? )
 
  


Reply


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
Script to check connection (and restart network if down) mac_phil Linux - Networking 15 06-21-2016 05:59 PM
wireless connection requires network restart bbcar Linux - Wireless Networking 1 11-21-2005 02:02 AM
Restart network connection? GT_Onizuka Linux - Networking 6 09-09-2004 06:30 PM
How to restart network connection satimis Debian 2 01-12-2004 02:30 AM
cron job to restart process if dead gborrageiro Linux - General 3 09-25-2002 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:41 AM.

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