[root@db01-51 scripts]# cat check_db.sh #!/bin/bash #local if [ "`netstat -lnt|grep 3306|awk -F "[ :]+" '{print $4}'`" = "3306" ] then echo "MySQL is running" else echo "MySQL is stoped" /etc/init.d/mysqld start fi