欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux Shell腳本實現(xiàn)檢測tomcat

 更新時間:2015年03月29日 14:40:43   投稿:hebedich  
這篇文章主要介紹了Linux Shell腳本實現(xiàn)檢測tomcat的方法,推薦給小伙伴們,需要的朋友可以參考下

Linux Shell腳本檢測tomcat并自動重啟

后臺運行命令 sh xxx.sh &
查看后臺任務(wù):jobs
召喚到前臺:fg jobs編號

可以刪掉while循環(huán)的代碼放到crontab里面定時執(zhí)行,可以將腳本直接后臺運行,

#!/bin/bash
while [ true ]
do
    url="http://www.dbjr.com.cn/";
    httpOK=`curl --connect-timeout 10 -m 60 --head --silent $url | awk 'NR==1{print $2}'`;
    if [ $httpOK == "200" ];then
        tomcat6=`ps -ef | grep tomcat | awk 'NR==1{print $1" "$2;}'`;
        user=`echo $tomcat6 | awk 'NR==1{print $1}'`;
        pid=`echo $tomcat6 | awk 'NR==1{print $2}'`;
        if [ $user != "tomcat" ]; then
            service tomcat6 start;
        else
            kill -9 $pid;sleep 5s;service tomcat6 start;service tomcat6 start;service tomcat6 status;
        fi;
    fi;
    sleep 5m;
done;

以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。

相關(guān)文章

最新評論