centos下tomcat保活
新建脚本文件
touch /home/monitor.sh
编辑
vim /home/monitor.sh
将下面的代码复制到编辑框保存退出
#!/bin/bash
work_path=/home
while true
do
is_live=`ps -ef |grep tomcat |grep -w 'tomcat'|grep -v 'grep'|awk '{print $2}'`
if [ -z "$is_live" ]; then
echo "start tomcat ..."
$work_path/tomcat/bin/startup.sh &
sleep 1
else
echo "is running ..."
sleep 10
fi
done
//设置权限
chomd +x /home/monitor.sh
开机自启
vim /etc/rc.d/rc.local
将/home/monitor.sh添加进去,保存退出即可