pgrep -x mysqld &> /dev/null if [ $? -ne 0 ];then bash /www/server/panel/script/rememory.sh /etc/init.d/mysqld start echo "监控到MySQL已停止,已执行重启计划,时间:`date "+%Y-%m-%d %H:%M:%S"`" >> /www/mysql_error.log fi如果MySQL自动停止,代码运行的日志会记录到这里:/www/mysql_error.log请自行宝塔中查看