#!/bin/bash
#while [ "2" -gt "1" ]
#do
log_command=`mysqladmin processlist | grep -i sleep | wc -l`
date=`date +%Y%m%d[%H:%M:%S]`
#echo $log_command
if [ "$log_command" -gt 250 ]
then
for i in `mysqladmin processlist | grep -i sleep | awk '{print $2}'`
do
mysqladmin kill $i
done
echo "$date : $log_command, sleep is too many i killed it" >> /data/killsleep/sleep.log
else
echo "$date : $log_command, not need to kill" >> /data/killsleep/sleep.log
fi
# sleep 180
#done
注意mysqladmin执行的用户,直接在命令行执行mysqladmin processlist | grep -i sleep | wc -l,
************************************************************************************
#!/bin/sh
PATH=$PATH:/usr/bin/
echo "show processlist" | mysql | grep Sleep | awk '{ if( $6> 60 ) print ("kill", $1, ";")}' | mysql
没有评论