From owner-freebsd-questions Wed May 17 12: 8:51 2000 Delivered-To: freebsd-questions@freebsd.org Received: from scientia.demon.co.uk (scientia.demon.co.uk [212.228.14.13]) by hub.freebsd.org (Postfix) with ESMTP id B4D5737B76D for ; Wed, 17 May 2000 12:08:38 -0700 (PDT) (envelope-from ben@scientia.demon.co.uk) Received: from strontium.scientia.demon.co.uk ([192.168.91.36] ident=exim) by scientia.demon.co.uk with esmtp (Exim 3.12 #1) id 12s81g-0008Dw-00; Wed, 17 May 2000 18:54:32 +0100 Received: (from ben) by strontium.scientia.demon.co.uk (Exim 3.12 #7) id 12s81g-0006Lo-00; Wed, 17 May 2000 18:54:32 +0100 Date: Wed, 17 May 2000 18:54:32 +0100 From: Ben Smithurst To: Doug Barton Cc: Marc Silver , freebsd-questions@freebsd.org Subject: Re: "Hangup" in mail from cron Message-ID: <20000517185432.B21557@strontium.scientia.demon.co.uk> References: <20000517074925.F58332@draenor.org> <39223554.E45081A@gorean.org> <20000517141912.I10128@strontium.scientia.demon.co.uk> <3922D463.C2B7E366@gorean.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3922D463.C2B7E366@gorean.org> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Doug Barton wrote: > Ben Smithurst wrote: >> >> Doug Barton wrote: >> >>> if [ -n "${PID}" ]; then >>> kill -HUP $PID >>> else >> >> How is $PID obtained? > > PID=`ps -auxww | grep httpd | grep root | grep -v grep | awk '{ print $2 > }'` Seems ok, as long as your script isn't called restart-httpd or something (and doesn't have httpd in the arguments). If nothing else shows an answer, have you considered tracing the cron job with "ktrace -i"? Of course that could generate a pretty large file if you're not careful. of course... PID=`ps -auxww | awk '/httpd/ && /root/ && !/awk/ { print $2 }'` Probably not portable enough for Sun though ;-) >> ps -auxww | grep '[h]ttpd' >> >> ok, so I'm very fussy about using too many processes when one fewer >> would do. :-) > > I certainly agree that reducing subshells is a worthy goal. However > that trick works with our (GNU) grep (although I've never seen a > satisfactory explanation of why) Well, because the string "httpd" present in the ps output for httpd matched "[h]ttpd" (because of course "[h]" means "match any character specified", which is just "h" here), but the string "[h]ttpd" in the ps output for grep doesn't match. If that's not satisfactory then you'll have to ask someone else for an explanation which is. > but it doesn't work with Sun's, and I need my scripts to be portable. fair enough. -- Ben Smithurst / ben@scientia.demon.co.uk / PGP: 0x99392F7D To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message