运行环境:Centos7
#!/bin/bash
#tomcat自动检测和开启服务的脚本
tomcat_path=$1
jarPath=$tomcat_path/bin/bootstrap.jar
#查看tomcat进程
tomcatPid(){
n=`ps -ef |grep -v grep |egrep $jarPath |awk '{print $2}'`
echo $n
}
#查看tomcat状态
statusTomcat(){
n=`ps -ef |grep -v grep |egrep $jarPath`
echo $n
}
#启动tomcat
startTomcat(){
$tomcat_path/bin/startup.sh
}
main(){
a=`statusTomcat`
if [ -z "$a" ];
then
{
startTomcat
}
else
{
echo "例行检查 服务正常"
}
fi
}
main $1


