#!/bin/sh date=`date +%Y%m%d\[%H:%M:%S]` n=`mysqladmin -uroot -p密码 processlist | grep -i sleep | wc -l` echo "sleep count:$n" if [ "$n" -gt 10 ]; then for i in `mysqladmin -uroot -p密码 processlist | grep -i sleep | awk '$12>1 {print $2}'` do mysqladmin -uroot -p密码 kill $i done echo "sleep is too many i killed it(time>0)." >> /www/killmysqlsleep.log echo "$date : $n" >> /www/killmysqlsleep.log fi