At 18:24 02/08/2002 +0900, you wrote:
>My internet connection always down after some hours. ( It is a provider ).
>So I want to write a script or program like this:
>
>checking the internet connection;
>if not connect {
> re-connect to my provider;
>} else {
> do nothing;
>}
>
>I want to set it to Cron so it can be run every 5 mins but,
>unfortunately, I don't know how to write it and what should I use.
>Shell? C? Perl?
I have the same issue. So I use this:-
### /sbin/netmon
#!/bin/bash
### get the address of the other side of my link
REMOTE=$(/sbin/ifconfig | /bin/grep P-t-P | /usr/bin/cut -c 42-58 |
/usr/bin/awk '{print $1}' )
### ping one packet at it
ping -c1 $REMOTE 1>/dev/null 2>/dev/null
### if no reply
if [ "$?" -gt "0" ]; then
### shutdown pppd
ifconfig ppp0 down
### shut down the DSL modem
killall speedmgmt
killall pppd
rmmod usb-ohci
rmmod speedtch
rmmod usbcore
### startup link (whatever script you use to start the connection)
/etc/rc.d/rc.dsl
fi
### end /sbin/netmon
Then that gets run every five minutes from cron.
I have a usb dsl modem so speedmgmt, usb-ohci, speedtch, usbcore are
specific to my setup - you most likely won't need them. Possibly you'll
just need to do:-
### shutdown pppd
ifconfig ppp0 down
killall pppd
### startup link
pppd
hih
nick@nexnix
--
redhat-list mailing list
Unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list