码迷,mamicode.com
首页 > 数据库 > 详细

MySQL服务健康检查脚本

时间:2015-12-27 23:37:10      阅读:381      评论:0      收藏:0      [点我收藏+]

标签:健康检查

#!/bin/sh
#date:2015-12-07
#filename:check_mysql.sh
#作者:linuxzkq

#Email:1729294227@qq.com
#version:v1.0

#port=`netstat -tunlp|grep 3306|wc -l`
#process=`ps -ef|grep mysqld|grep -v grep|wc -l`
value=`/application/mysql/bin/mysql -u root -poldboy -e "select version();" >/dev/null 2>&1`

while  true
do
if [  $?  -ne  0  ]
  then
      #echo "ERROR! MySQL is not running"
      /etc/init.d/mysqld start
else
      echo "MySQL is running,now!"
fi
  sleep 5
value=`/application/mysql/bin/mysql -u root -poldboy -e "select version();" >/dev/null 2>&1`
if [  $?  -ne  0  ]
  then
      #echo "ERROR! MySQL is not running"
      /etc/init.d/mysqld start
else
      echo "MySQL is running,now!"
fi

  sleep 5

done

本文出自 “兰州linux运维” 博客,请务必保留此出处http://linuxzkq.blog.51cto.com/9379412/1728877

MySQL服务健康检查脚本

标签:健康检查

原文地址:http://linuxzkq.blog.51cto.com/9379412/1728877

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!