I wrote a script for mysql process check. I think about my online search experience when I was a beginner. I suddenly wanted to laugh. I am an O & M engineer. I also want to say "iamaco !". #! /Bin/bash # DATE2013/11/25 # MAILgccmx@163.com # FUNCTIONcheckthemysqlstatus, ifnotrunstartmysql. # CreatebyCh
I wrote a script for mysql process check. I think about my online search experience when I was a beginner. I suddenly wanted to laugh. I am an O & M engineer and want to say "I am a Coder !".
#!/bin/bash#DATE 2013/11/25#MAIL gccmx@163.com#FUNCTION check the mysql status,ifnot run start mysql.#Create by Chenchao GaocheckMysql(){CMDCHECK=`lsof -i:3306&>/dev/null`Port="$?"PIDCHECK=`ps aux|grep mysqld|grep -v grep`PID="$?"if[ "$Port"-eq "0"-a "$PID"-eq 0];thenreturn200elsereturn500fi}startMysql(){/etc/init.d/mysqld start}checkMysqlif[ $? == 200];thenecho "Mysql is running..."elsestartMysqlcheckMysqlif[ $? != 200];thenwhiletruedokillall mysqldsleep 2[ $? != 0]&&breakdonestartMysqlfifi