TB0ne |
05-05-2009 09:21 AM |
Quote:
Originally Posted by tinymark
(Post 3530740)
I have a wired network operating with a router. Every now and then my ISP goes down and I have to run "service network restart" followed by "service NetworkManager restart" to reconnect. What I would like to do is have some kind of script that monitors the network connection and automatically reconnect. I program in a number of web related languages but have never tried my hand at Linux programming. All tips and pointers would be appreciated. TIA
|
Well, what does your linux server know about, when the ISP goes down? Do any messages get put in your syslogs, or do you have any traces on your system?
If you've got something in syslog (like "LINK DOWN", or some such message), there are lots of logwatch programs you can use, to run whatever commands you want, when they see a certain message. Just put the commands in a shell script file, chmod 755 the file, then you can execute it.
If not, since you know web languages (PHP?), you can easily use one of them to call system programs like ping, etc. You can write a program to ping a website (like www.google.com), and if it doesn't get a response, issue those commands you specified above. You can put a sleep in the program, or you can CRON execution for every five minutes or so...
|