使用一个脚本监控mysql进程

#!/bin/sh
ps -fe|grep mysqld |grep -v grep
if [ $? -ne 0 ]
then
echo "start process....."
service mysql start
else
echo "runing....."
fi
 
DATE=`date +%Y%m%d%H%M%S`
echo $DATE >> /backup/mysql/test.txt

0表示存在的
$? -ne 0 不存在,$? -eq 0 存在

vi /etc/crontab
*/5 *	* * * 	root	/backup/mysql/mysql.sh
crontab /etc/crontab

加入自动执行,每5分钟监测一次

如果挂了,自动重启


This entry was posted in Linux, 数据库 and tagged , , , . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/mysql-restart/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

  

About Me

静水流深,水滴石穿