歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Linux下tomcat服務自動重啟

Linux下tomcat服務自動重啟

日期:2017/3/3 13:50:32   编辑:Linux技術

創建restart.sh腳本,代碼如下

[code]#!/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

[code]*/1 * * * * /home/appusr/shell/ar-restart.sh

Copyright © Linux教程網 All Rights Reserved