10

Centos 7 使用Shell脚本定时检查MySql服务运行状态 - 包子啥汤

 3 years ago
source link: https://www.deaboway.com/centos-7-%e4%bd%bf%e7%94%a8shell%e8%84%9a%e6%9c%ac%e5%ae%9a%e6%97%b6%e6%a3%80%e6%9f%a5mysql%e6%9c%8d%e5%8a%a1%e8%bf%90%e8%a1%8c%e7%8a%b6%e6%80%81.html#.X-EgNxMRWo8
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Centos 7 使用Shell脚本定时检查MySql服务运行状态

MySQL监控脚本:

#!/bin/bash
pgrep mysqld &> /dev/null
if [ $? -gt 0 ]
then
echo "`date` ERROR! MySQL is not running" >> /home/mysqlstatus.log
systemctl start mysqld >> /home/mysqlstatus.log
else
echo "`date` SUCCESS! MySQL running" >> /home/mysqlstatus.log
fi
10846c772c1c3b07d668a0306dcaa7d0-3.png

授权执行权限:

chmod 755 checkmysql.sh

加入Crontab,10分钟check一次

*/10 * * * * /home/checkmysql.sh

欢迎关注我的微信公众号:

qrcwechat.jpg

如无特殊说明,文章均为本站原创,转载请注明出处!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK