Linux下tomcat服务自动重启

来源:互联网 发布:mysql批量修改数据 编辑:程序博客网 时间:2024/04/29 06:49

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

#!/bin/bashtest=`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.logfi

添加定时任务

[appusr@localhost shell]$ crontab -e

*/1 * * * * /home/appusr/shell/ar-restart.sh
1 0
原创粉丝点击