From owner-freebsd-questions@FreeBSD.ORG Fri May 2 08:22:12 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3892737B401 for ; Fri, 2 May 2003 08:22:12 -0700 (PDT) Received: from thalia.otenet.gr (thalia.otenet.gr [195.170.0.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 052DF43F75 for ; Fri, 2 May 2003 08:22:11 -0700 (PDT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-a056.otenet.gr [212.205.215.56]) by thalia.otenet.gr (8.12.9/8.12.9) with ESMTP id h42FLumX023913; Fri, 2 May 2003 18:22:01 +0300 (EEST) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.9/8.12.9) with ESMTP id h42FLtJa000882; Fri, 2 May 2003 18:21:55 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.12.9/8.12.9/Submit) id h42Eod7K019768; Fri, 2 May 2003 17:50:39 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 2 May 2003 17:50:39 +0300 From: Giorgos Keramidas To: Paul Hamilton Message-ID: <20030502145039.GD98449@gothmog.gr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: cc: freebsd-questions@freebsd.org Subject: Re: auto restarting a ppp connection X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 May 2003 15:22:12 -0000 On 2003-05-02 21:44, Paul Hamilton wrote: > Hi All, > > I am running FreeBSD 4.7, and using the built in ppp (and ppp nat), > software to make a pppoe connection. > > Once or twice a month my ISP does something that causes my connection > to be blocked. The only way to fix this is to kill the ppp connection > and re-start it. I have tried to put the whole routine into a script, > ie, find the pid, kill it, wait, then restart the ppp connection. The > idea, was that I could link it with a ping tester, then when I miss > 'x' number of pings, restart the connection. This is what I used:- > > --snip--- > > PPP=`ps -ax | grep "ppp -nat" | grep -v "grep" | cut -c 1-6` > if test $PPP > #if test $PPP != "" > then > kill -15 $PPP > echo Wait for 5 seconds to properly kill the old PPP process > printf "%s" "." > sleep 1 > printf "%s" "." > sleep 1 > printf "%s" "." > sleep 1 > printf "%s" "." > sleep 1 > printf "%s" "." > sleep 1 > printf "%s\n" "." > sleep 1 > else > echo > echo No PPP process found to kill > fi > ---snip--- > > I found that my script had problems with killing the ppp pid, in that it > didn't really kill the ppp process, until the script had exited. After the 5 seconds have passed it's relatively "safe" to kill -9 $PPP. Whenever there is a problem with my PPP connection, I write something like this: killall ppp ; sleep 5 ; killall ppp ; sleep 10 ; killall -9 ppp :)