感谢你的到来
一起学习进步

宝塔添加监控Nginx|mysql|redis|php计划任务,重启

1.监控Nginx

#!/bin/bash
# Linux监控Nginx服务,关闭就自动重启
nginx_procnum=`ps -ef|grep "nginx"|grep -v grep|wc -l`

if [ $nginx_procnum -eq 0 ]
then
echo $(date) “Success,Nginx重启成功!” >> /var/log/nginxmonitor.log
/etc/init.d/nginx start
else
sleep 5
echo “Nginx正常运行中…”
fi

2.监控mysql

#!/bin/bash
# Linux监控MySQL服务,关闭就自动重启
pgrep -x mysqld &> /dev/null
if [ $? -ne 0 ];then
bash /www/server/panel/script/rememory.sh
/etc/init.d/mysqld start
echo "监控到MySQL已停止,已执行重启计划,时间: `date "+%Y-%m-%d %H:%M:%S"` " >> /www/mysql_jiankong.log
fi

3.监控redis

#!/bin/bash
# Linux监控redis服务,关闭就自动重启
pgrep -x redis &> /dev/null
if [ $? -ne 0 ];then
/etc/init.d/redis start
fi
/www/redis_jiankong.log

4.监控php

/etc/init.d/php-fpm-54 restart ;
/etc/init.d/php-fpm-82 restart ;

#!/bin/bash
# Linux监控PHP服务,关闭就自动重启
pgrep -x php-fpm &> /dev/null
if [ $? -ne 0 ];then
/etc/init.d/php-fpm-54 restart ;
/etc/init.d/php-fpm-72 restart ;
/etc/init.d/php-fpm-81 restart ;
/etc/init.d/php-fpm-82 restart ;
echo “监控到php56已停止,已执行重启计划,时间: `date “+%Y-%m-%d %H:%M:%S”` ” >> /www/php_jiankong.log
fi



赞(0) 打赏
未经允许不得转载:IT起义网络科技 » 宝塔添加监控Nginx|mysql|redis|php计划任务,重启
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

微信:345497590QQ 345497590

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏