Centos监控mysql服务是否正常运行,如果停止启动之
2021-04-05 16:25:15
/mysql_monitor.sh
#!/bin/bash
pgrep -x mysqld &> /dev/null
if [ $? -ne 0 ]
then
echo "At time: `date` :MySQL is stop .">> /mysql_listen.log
/sbin/service mysqld restart
else
echo "At time: `date` :MySQL server is running .">> /mysql_listen.log
fi
计划任务
crontab -e
*/5 * * * * /mysql_monitor.sh
*/5 * * * * /usr/bin/php /html/rjob.php
#!/bin/bash
pgrep -x mysqld &> /dev/null
if [ $? -ne 0 ]
then
echo "At time: `date` :MySQL is stop .">> /mysql_listen.log
/sbin/service mysqld restart
else
echo "At time: `date` :MySQL server is running .">> /mysql_listen.log
fi
计划任务
crontab -e
*/5 * * * * /mysql_monitor.sh
*/5 * * * * /usr/bin/php /html/rjob.php