Date: Wed, 17 May 2000 18:54:32 +0100 From: Ben Smithurst <ben@scientia.demon.co.uk> To: Doug Barton <DougB@gorean.org> Cc: Marc Silver <marcs@draenor.org>, freebsd-questions@freebsd.org Subject: Re: "Hangup" in mail from cron Message-ID: <20000517185432.B21557@strontium.scientia.demon.co.uk> In-Reply-To: <3922D463.C2B7E366@gorean.org> References: <Pine.BSF.4.21.0005161231480.53178-100000@dt051n0b.san.rr.com> <20000517074925.F58332@draenor.org> <39223554.E45081A@gorean.org> <20000517141912.I10128@strontium.scientia.demon.co.uk> <3922D463.C2B7E366@gorean.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000517185432.B21557>
