无限星辰工作室-客户无限互联网动力之源
标题:
定时检查Mysql状态 重启mysql
[打印本页]
作者:
crx349
时间:
2019-12-2 12:45
标题:
定时检查Mysql状态 重启mysql
脚本:
#!/bin/bash
count=0
#尝试循环10次后退出
while [ $count -lt 10 ]
do
pgrep -x mysqld >/dev/null
if [ $? -ne 0 ];then
count=$[$count+1]
#不能使用service mysqld start,启动不成功
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
else
echo “MySQL server is running .”
break
fi
done
if [ $count -ne 0 ];then
#写入日志文件,不需要可以注释掉
echo -e “At time: ` date "+%Y-%m-%d %H:%M:%S"` :MySQL is stop . Trying to restart $count times .\n” >>/root/sqllog.txt
fi
复制代码
原文链接:
https://blog.csdn.net/qq_40622375/article/details/95739034
欢迎光临 无限星辰工作室-客户无限互联网动力之源 (https://xmspace.net/)
Powered by Discuz! X3.4