Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: Shell script to check if Tomcat is running?

Oscar Carrillo

2003-12-01

Replies:

On Mon, 1 Dec 2003, Tim Funk wrote:

> 2 really simple ways
>
>
> -----------------------------
> # Assume tomcat is the only java process
> COWBELL=`ps -ef | grep java| grep -v grep | wc -l`
> if [ $COWBELL > 0 ]; then
>   echo "Woohoo - the process is there";
> fi
> -----------------------------

This might depend on the shell used, but I think ">" should be "-gt".

Here's another option in case you have java programs running that aren't
Tomcat:

#this is all one line
COWBELL=`ps ax --width=1000 | grep \
"[o]rg.apache.catalina.startup.Bootstrap \
start" | awk '{printf $1 " "}' | wc | awk '{print $2}'`
#end of one line
if [ $COWBELL -gt 0 ]; then
  echo "Woohoo - Tomcat is there";
fi

Cheers,
Oscar


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.