Ubuntu下監控服務

棲息之鷹發表於2020-04-16

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

 

相關文章