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

多种方式来判断mysql是否启动

时间:2019-08-05 09:12:42      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:stop   moni   oca   net   tor   sql   int   remote   map   

#!/bin/sh

monitor mysql run

#by zkg 2019-08-05

#下面是多种方式来判断mysql是否启动
#local 监控
#if [ "netstat -lnt |grep 3306|awk ‘{print $4}‘|awk -F: ‘{print $2}‘" = "3306" ]
#if [ ps -ef |grep mysql|grep -v grep|wc -l -gt 0 ]
#if [ netstat -lntup|grep mysqld|wc -l -gt 0 ]
#if [ lsof -i tcp:3306|wc -l -gt 0 ]
#remote 监控
if [ nmap 192.168.31.75 -p 3306 2>/dev/null|grep mysql|wc -l -gt 0 ]
then
echo "mysql is running"
else
echo "mysql is stopped"
/data/mysql/mysql start
fi

多种方式来判断mysql是否启动

标签:stop   moni   oca   net   tor   sql   int   remote   map   

原文地址:https://blog.51cto.com/1009516/2426555

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