使用shell脚本监控tomcat

#! /bin/sh

#死循环
while :
do

#查找tomcat的pid

ui=$(ps x |grep catalina |grep tomcat |grep -v grep|awk '{print $1}')

echo 'tomcat pid is' $ui
if  
  [ "$ui" == ""  ] ;then

#如果TOMCAT 的PID不存在就启动tomcat

echo "tomcat is shutdown ,now start up tomcat...."
        export JAVA_HOME=/opt/jdk/1.6
        export PATH=$JAVA_HOME/bin:$PATH
        export LANG=zh_CN.GB18030
        export LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN
 #startup tomcatui
 /opt/unimas/tomcatui/bin/startup.sh

#睡眠4秒让tomcat启动
        sleep 4
echo "tomcat restart ok.."

else
        echo "tomcat is running...."
fi

done

你可能感兴趣的:(java,jdk,tomcat,UI,脚本)