curdir=`pwd`
tomcat="/soft/tomcat-ite"
PIDS=`ps -ef | grep java | grep "$tomcat" |awk '{print $2}'`
if [ ! -z "$PIDS" ]; then
sh $tomcat/bin/shutdown.sh
echo -e "Stopping the $tomcat $PIDS..."
c=1
while [ $c -gt 0 ]; do    
    echo -e ".\c"
    sleep 1
    let "c++"
    for PID in $PIDS ; do
        PID_EXIST=`ps -f -p $PID | grep java`
	if [ -z "$PID_EXIST" ]; then
	    c=0
            break
        fi
	if [ $c -eq 5 ]; then
	    echo "kill $PID"
	    kill $PID
	fi
	if [ $c -eq 10 ]; then
	    echo "kill -9 $PID"
	    c=0
	    kill -9 $PID
	fi
    done
done
else
echo "Not Running. $tomcat"
fi
echo "Starting... $tomcat"
sh $tomcat/bin/startup.sh
if [ $# -eq 0 ]; then
tail -f $tomcat/logs/catalina.out
fi
