让 tomcat 一直运行,不会挂掉的脚本。

#!/bin/bash

#死循环
while :
do

#查找tomcat的pid

pid_1=$(ps x | grep tomcat-hnjz-nk |grep -v grep|grep -v tomcat-hnjz-nkzx |awk ‘{print $1}’)
pid_2=$(ps x | grep tomcat-hnjz-nkzx |grep -v grep|awk ‘{print $1}’)
pid_3=$(ps x | grep tomcat-hnjz-socket |grep -v grep|awk ‘{print $1}’)

#如果pid为空则启动相应tomcat进程
if
[ “$pid_1” == “” ] ;then
/home/tomcat-hnjz-nk/bin/startup.sh >/dev/null
sleep 4
fi

if
[ “$pid_2” == “” ] ;then
/home/tomcat-hnjz-nkzx/bin/startup.sh >/dev/null
sleep 4
fi

if
[ “$pid_3” == “” ] ;then
/home/tomcat-hnjz-socket/bin/startup.sh >/dev/null
sleep 4
fi
done

Leave a Reply

Your email address will not be published. Required fields are marked *