一个手工删除mysql的sleep线程的小脚本


#It is used to kill processlist of mysql sleep

#!/bin/sh

MYSQLADMIN="/usr/local/mysql3306/bin/mysqladmin"

while :

do

  n=`$MYSQLADMIN processlist -uadmin -padmin|grep -i sleep |wc -l`

  date=`date +%Y%m%d\[%H:%M:%S]`

  echo $n

  if [ "$n" -gt 10 ]

  then

  for i in `$MYSQLADMIN processlist -uadmin -padmin|grep -i sleep |awk '{print $2}'`

  do

     $MYSQLADMIN -uadmin -padmin kill $i

  done

  echo "sleep is too many I killed it " >> /tmp/sleep.log

  echo "$date : $n" >> /tmp/sleep.log

  fi

  sleep 1

done


你可能感兴趣的:(mysql,local,sleep,手工,killed)