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)文章
Shell腳本入門之編寫格式與執(zhí)行方式的實現(xiàn)
這篇文章主要介紹了Shell腳本入門之編寫格式與執(zhí)行方式的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12linux 中的ls命令參數(shù)詳解及l(fā)s命令的使用實例
這篇文章主要介紹了linux 中的ls命令參數(shù)詳解及l(fā)s命令的使用實例,需要的朋友可以參考下2017-08-08用expect實現(xiàn)ssh自動登錄服務(wù)器并進行批量管理的實現(xiàn)方法
這篇文章主要介紹用expect實現(xiàn)ssh自動登錄服務(wù)器并進行批量管理的實現(xiàn)方法,需要的朋友可以參考下2013-02-02