Running freebsd-7.0
I use a small script in a jail to check if Apache is running and if
not, restart it.
#!/bin/sh
#if ps -ax | grep -v grep | grep -i httpd
#then
#echo Apache is alive..
#else
#echo Apache is dead, but will be launched.
#/usr/local/etc/rc.d/apache22 start
On 24.08.2012 00:57, Jack Stone wrote:
[...]
How can I modify my script to see only the host based on the bottom line
above?
pgrep(1) has an option (-j jid) to either include jails by
given id or to exclude them (-j none).
HTH,
Frank Reppin
--
43rd Law of Computing:
Anything that can
On 24.08.2012 02:14, Jack Stone wrote:
Thanks, I tried that but pgrep only displayed the PIDs. I guess I wasn't
using proper switches.
Yes - and this should be enough.
If pgrep returns PIDs - then this is the same as 'true' in your
'if' condition - if it returns nothing, the 'else' part is
There's an errorneous extra ^ in line 6 - please remove this
character.
Fixed version should look like:
#!/bin/sh
PROCESS_PATTERN=^/usr/local/sbin/saslauthd
PGREP=/bin/pgrep
if ${PGREP} -q -j none -f ${PROCESS_PATTERN}; then
echo -e OK
else
echo -e FAIL
fi
frank\
--
43rd Law of