Linux下tomcat服务自动重启

创建restart.sh脚本,代码如下

#!/bin/bash

test=`ps aux|grep tomcat8081|grep -v grep`

if [ -n "$test" ]
        then
                echo "$(date) tomcat is ok">> /home/appusr/shell/logs/autostart-acc.log
        else
                sh /home/appusr/tomcat8081/bin/startup.sh &>/dev/null
                echo "$(date) restart tomcat ">> /home/appusr/shell/logs/autostart-err.log

fi

添加定时任务

[appusr@localhost shell]$ crontab -e

*/1 * * * * /home/appusr/shell/ar-restart.sh

你可能感兴趣的:(shell)