kill-mysql-sleep.sh

时间:2022-09-04 22:07:38
#!/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 ]
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
#done
~