检测tomcat关闭的shell

#!/bin/sh
pid=`ps aux | grep tomcat | grep -v grep | grep -v retomcat | awk '{print $2}'`
echo $pid
if [ -n "$pid" ]
then
{
echo ===========shutdown================
/etc/init.d/tomcat6 stop
sleep 2
pid=`ps aux | grep tomcat | grep -v grep | grep -v retomcat | awk '{print $2}'`
if [ -n "$pid" ]
then
{
sleep 2
echo ========kill tomcat begin==============
echo $pid
kill -9 $pid
echo ========kill tomcat end==============
}
fi
sleep 2
echo ===========startup.sh==============
/etc/init.d/tomcat6 restart
}
else
echo ===========startup.sh==============
/etc/init.d/

相关推荐