使用宝塔面板,最近发现Nginx 、MySQL服务重启后无法自动启动,添加开机启动命令无效,查看网贴找到《自动重启 shell脚本》,写在这里记录一下吧
1 2 3 4 5 6 7 8 9 10 11 |
nginx_procnum=`ps -ef|grep "nginx"|grep -v grep|wc -l` if [ $nginx_procnum -eq 0 ] then echo "start nginx..." /etc/init.d/nginx start else echo "no cmd" fi // 然后添加定时任务;每分钟执行一次 |
然后添加定时任务;每分钟执行一次
将全部的 redis,nginx,php,mysqld 判断并重启;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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-71 start elif [ $nginx_procnum -eq 0 ] then echo "start nginx..." /etc/init.d/nginx start elif [ $mysql_procnum -eq 0 ] then echo "start mysql..." /etc/init.d/mysql start elif [ $redis_procnum -eq 0 ] then echo "start redis..." /etc/init.d/redis start else echo "no cmd" fi |