--------------------------------------------------------
--------------------------------------------------------------------------------------
#It is used to kill processlist of mysql sleep~~~
#!/bin/sh
while :
do
n=`/opt/mysql/bin/mysqladmin processlist|grep -i sleep |wc -l`
date=`date +%Y%m%d/[%H:%M:%S]`
echo $n
# id=`/opt/mysql/bin/mysqladmin processlist |grep Sleep |awk '{if ($12 > 100) {print $2}}'`
# echo "$date : $n" >> /tmp/sleep.log
# if [ id != "" ]
# then
# for j in $id
# do
# /opt/mysql/bin/mysqladmin kill $j
# echo "$date : sleep is to long " >> /tmp/sleep.log
# fi
#
if [ "$n" -gt 60 ]
then
for i in `/opt/mysql/bin/mysqladmin processlist|grep -i sleep |awk '{print $2}'`
do
/opt/mysql/bin/mysqladmin kill $i
done
echo "sleep is too many i killed it " >> /tmp/sleep.log
echo "$date : $n" >> /tmp/sleep.log
fi
sleep 1
done
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com