Ubuntu下监控服务

Ubuntu下监控服务,本方案是根据端口号,如果此端口号不活动,则认为服务停止,那么就重启服务

#!/bin/bash
cur_dateTime=`date +%Y-%m-%d,%H:%m:%S`
a=`lsof -i:8082 | wc -l`

if [ "$a" -gt "0" ];then
    /bin/bash /opt/cook-prod/backend/restart.sh
    echo "$cur_dateTime cook running" >> /opt/job/log/cook_restart.job
else
    echo "$cur_dateTime restart job" >> /opt/job/log/cook_restart.job
fi

 

posted @ 2020-04-16 09:45  栖息之鹰  阅读(324)  评论(0编辑  收藏  举报