############################################################################# # Kill all processlist According to status. # -h: 主机IP # -u: 用户名 # -p: 密码 #############################################################################
host = '' user = '' pwd = '' status = ''
while : do n=`mysqladmin processlist -h$host -u$user -p$pwd | grep -i $status | wc -l` date=`date +%Y%m%d\[%H:%M:%S]` echo $n
if [ "$n"-gt10 ] then for i in `mysqladmin processlist -h$host -u$user -p$pwd | grep -i $status | awk '{print $2}'` do mysqladmin processlist -h$host -u$user -p$pwd kill $i done
echo "$status is too many need killed it " >> /tmp/kill.log echo "$date : $n" >> /tmp/kill.log fi sleep 1 done