#!/bin/bash res=`netstat -lntup | grep 3306 | awk -F '[ :]+' '{print $5}'` if [ $res -eq "3306" ];then echo "Mysql is Running" else echo "Mysql is Stopped" fi
#!/bin/bash res=`netstat -lntup | grep 3306 | awk -F '[/]+' '{print $NF}'` if [ $res == "mysqld" ];then echo "Mysql is Running" else echo "Mysql is Stopped" fi
[root@rhel6 nginx-1.10.3]# nc -w 2 127.0.0.1 3306 &>/dev/null && echo success success