#! /bin/bash # # service-restart Automount system service in the specified direcotry. # # chkconfig: 2345 90 10 # description: 这个程序用来监控服务器服务软件,以程序挂掉后重启 Author is Sindsun 2019年12月9日15:40:45. # ! /bin/sh while true do phpfpm_procnum=`ps -ef|grep "php-fpm"|grep -v grep|wc -l` nginx_procnum=`ps -ef|grep "nginx"|grep -v grep|wc -l` mysql_procnum=`ps -ef|grep "mysqld"|grep -v grep|wc -l` redis_procnum=`ps -ef|grep "redis"|grep -v grep|wc -l` if [ $phpfpm_procnum -eq 0 ] then echo "start php-fpm..." /etc/init.d/php-fpm start >> /var/log/listen_service_start.log 2>&1 elif [ $nginx_procnum -eq 0 ] then echo "start nginx..." /usr/local/nginx/sbin/nginx >> /var/log/listen_service_start.log 2>&1 elif [ $mysql_procnum -eq 0 ] then echo "start mysql..." systemctl start mysqld >> /var/log/listen_service_start.log 2>&1 elif [ $redis_procnum -eq 0 ] then echo "start redis..." systemctl start redis >> /var/log/listen_service_start.log 2>&1 else #echo "no cmd" fi sleep 30 #每30秒检查一轮 done
版权声明:
此文为本站源创文章[或由本站编辑从网络整理改编],
转载请备注出处:
[狂码一生]
https://www.sindsun.com/articles/24/125
[若此文确切存在侵权,请联系本站管理员进行删除!]
--THE END--