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

 

你可能感兴趣的:(Ubuntu下监控服务)