kill-mysql-sleep.sh

#!/bin/bash
#while :
#do
  n=`/usr/bin/mysqladmin -uroot -pXXXXX  processlist | grep -i sleep | wc -l`
  date=`date +%Y%m%d\[%H:%M:%S]`
  echo $n

  if [ "$n" -gt 1 ]
  then
    for i in `/usr/bin/mysqladmin -uroot -pXXXXX  processlist | grep -i sleep | awk '{print $2}'`
    do
      /usr/bin/mysqladmin -uroot -pXXXXX kill $i
    done
#    echo "sleep is too many i killed it" >> /tmp/sleep.log
#    echo "$date : $n" >> /tmp/sleep.log
  fi
#sleep 5
#done
~                         

 

posted @ 2017-01-12 10:00  snale1989  阅读(256)  评论(0编辑  收藏  举报