使用shell脚本监控tomcat状态
时间:2014-12-05 13:03 来源:linux.it.net.cn 作者:IT
如下脚本使用一个while循环不停的监控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
(责任编辑:IT)
如下脚本使用一个while循环不停的监控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(责任编辑:IT) |