当前位置:Gxlcms > 数据库问题 > 多种方式来判断mysql是否启动

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

时间:2021-07-01 10:21:17 帮助过:14人阅读

#!/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   

人气教程排行