Date: Fri, 17 Jan 1997 13:17:23 +0100 (MET) From: Zahemszky Gabor <zgabor@CoDe.hu> To: freebsd-questions@freebsd.org (FreeBSD questions) Subject: Re: Crontab for killing and restarting named Message-ID: <199701171217.NAA00500@CoDe.hu> In-Reply-To: <199701170922.BAA09807@connectnet1.connectnet.com> from That Doug Guy at "Jan 17, 97 01:21:26 am"
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 Yes, because it's name contains ``named'', too, and awk find it. 1) I found it in AEllen Frisch's Essential System Administration: instead of: .... | grep foo | grep -v grep it would be good: .... | grep '[f]oo' It's cheaper, because it uses only 1 grep process, and 1 pipe, not two of them. (And if you use grep in the original instead of fgrep, the time and memory are ~ same.) 2) Your problem has a much cheaper solution: kill -9 `cat /var/run/named.pid` in your script, or use the systems /usr/sbin/named.restart or /usr/sbin/ndc restart scripts, designed for this problem. Bye, Gabor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701171217.NAA00500>