centos 監控進程,並自動重啟


 

 

編輯Crontab

crontab -e

按i進行編輯

*/1 * * * * /root/monitor.sh     # 每分鍾運行一遍monitor.sh腳本
0 5 * * * /sbin/reboot           # 每天凌晨5點自動重啟服務器
*/1 * * * * /root/monitor.sh     # 每分鍾運行一遍monitor.sh腳本
0 5 * * * /sbin/reboot           # 每天凌晨5點自動重啟服務器

 

重啟服務

systemctl restart crond

monitor.sh

#!/bin/sh
echo "==================start monitor==============="
#define  commonprocessnum
commonprocessnum=1
#define sleeptime,4 miniutes sleeptime=30 #iternal internal=5 #3 define pypath pypath='/data/centos_env/run_exe' #monitor the othe process whether has run #while (( 1 < 11 )) #do # 3 check the ptps and if no running then start the prcess gfid=`ps -ef | grep -i feature-extract |grep -v 'grep'| wc -l` if [ ${gfid} -ge ${commonprocessnum} ]; then sleep 1 else cd $pypath ./feature-extract & sleep ${internal} echo "=========3 start the feature-extract process " fi #sleppzzz sleep ${sleeptime} #done

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM