定期检查mysql服务重启后自动重启
mysql.sh
#!/bin/bash
pgrep -x mysqld &> /dev/null
if [ $? -ne 0 ]
then
echo "At time: `date` :MySQL is stop .">> /var/log/mysql_messages
service mysql start
echo "At time: `date` :MySQL server is stop."
else
echo "MySQL server is running ."
fi
开启定时任务
crontab -e
*/2 * * * * /home/zhangyuqing/mysql.sh
service cron restart
这样就可以了,哈哈哈