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
授权执行权限:
chmod 755 checkmysql.sh
加入Crontab,10分钟check一次
*/10 * * * * /home/checkmysql.sh