From owner-freebsd-questions Fri Jan 17 02:20:04 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id CAA21896 for questions-outgoing; Fri, 17 Jan 1997 02:20:04 -0800 (PST) Received: from gatekeeper.barcode.co.il (gatekeeper.barcode.co.il [192.116.93.17]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id CAA21854 for ; Fri, 17 Jan 1997 02:19:57 -0800 (PST) Received: (from nadav@localhost) by gatekeeper.barcode.co.il (8.7.5/8.6.12) id MAA28247; Fri, 17 Jan 1997 12:18:55 +0200 (IST) Date: Fri, 17 Jan 1997 12:18:55 +0200 (IST) From: Nadav Eiron To: That Doug Guy cc: "FreeBSD-questions@freebsd.org" Subject: Re: Crontab for killing and restarting named In-Reply-To: <199701170922.BAA09807@connectnet1.connectnet.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Fri, 17 Jan 1997, That Doug Guy wrote: > Ok, this is driving me nutty. I need to kill named once a day, and then > restart it. First I tried a command line to do this in the crontab, but I couldn't get > that to work, so I decided to use a script. Here is the script that I ended up with: > > #!/bin/sh > PID=`/bin/ps ax | /usr/bin/grep named | /usr/bin/grep -v grep | /usr/bin/awk > '{print $1}'` > /bin/kill -9 ${PID} > /bin/sleep 5 > /usr/sbin/named > > The only problem is, it doesn't work properly. When I run it from the command > line, it kills named, then hangs. I have to kill the script with ^C. Here is the error > (named was pid 8781): > > [root@dalnet ~/bin] 123# kill-named It seems that the process that runs the script will also come up in your little grep/awk pipe (it has named in it's name, and doesn't have grep)! > Killed > kill: [root@dalnet ~/bin] 124# 8793: No such process > > It seems to be trying to kill the processes that start as a result of the script too, but > I'm not sure why. I tried it without the last 2 lines, same result. If I can just get it > to kill the process and then exit cleanly I can restart named with a crontab one > minute later than the one that runs the script, but I'd really like to avoid having it > down for a full minute if possible. > > Apologies to anyone who thinks this is not a proper use of this list, but it > *is* a FreeBSD system. :) Flames in private please. > > Thanks, > > Doug > > Nadav