linux Web服务程序监控shell脚本

释放双眼,带上耳机,听听看~!

#!/bin/bash
pgrep=/usr/bin/pgrep
killall=/usr/bin/killall
nohup=/usr/bin/nohup
curl=/usr/bin/curl
sleep=/bin/sleep
service=CC
host=127.0.0.1
port=8080
count=0
max=4
check_web(){
while :
do
check_pid
result=$($curl http://$host:$port/android_ping)
echo "result:$result"
if [ "$result" ] ; then
count=0
else
let count+=1
echo "exception:$count"
if [ $count -gt $max ] ; then
$killall -9 $service && $nohup /home/CC/CC $port &
count=0
fi
fi    
$sleep 3
done
}
check_pid(){
if [ -n "

1
1`

$pgrep $service

1
1`

" ] ; then
echo "CC service was already started by another way"
else
echo "CC service was not started"
echo "Starting service …"
$nohup /home/CC/CC $port &
echo "CC service was exited!"
fi
}
check_web

给TA打赏
共{{data.count}}人
人已打赏
安全技术安全运维

Windows服务器如何发现被黑

2018-5-20 12:24:31

安全技术

网站制作需要素材的实用网站

2021-12-21 16:36:11

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索