0514-86177077
9:00-17:00(工作日)
Linux Shell腳本檢測tomcat并自動重啟
后臺運行命令 sh xxx.sh 查看后臺任務:jobs 召喚到前臺:fg jobs編號
可以刪掉while循環的代碼放到crontab里面定時執行,可以將腳本直接后臺運行,
#!/bin/bash while [ true ] do url="https://www.jb51.net/"; 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;
以上所述就是本文的全部內容了,希望大家能夠喜歡。
標簽:遵義 大興安嶺 安康 大慶 上饒 三門峽 江西 仙桃
上一篇:shell版Nginx日志蜘蛛爬取查看腳本
下一篇:linux shell實現守護進程腳本
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8