Avr 192012
 

Créez ce script et lancez le régulièrement avec un cron :

#!/bin/bash
 
USER=root
PASS=XXXXXX
TIME=120
mysql=/usr/bin/mysql
grep=/bin/grep
mysqladmin=/usr/bin/mysqladmin
 
## KILL SLEEP > $TIME
for requete in $($mysql -u$USER -p$PASS INFORMATION_SCHEMA -B -e'select id from PROCESSLIST where Command like "Sleep" and TIME >= "'$TIME'"'| $grep -v id); do 
       $mysqladmin -u$USER -p$PASS kill $requete 
done
 
## KILL SELECT > $TIME
for requete in $($mysql -u$USER -p$PASS INFORMATION_SCHEMA -B -e'select id from PROCESSLIST where INFO like "select%" and TIME >= "'$TIME'"'| $grep -v id); do 
       $mysqladmin -u$USER -p$PASS kill $requete 
done
Fév 192012
 

Kill tous les sleeps de plus de 10s :

for requete in $(mysql INFORMATION_SCHEMA -B -e'select id from PROCESSLIST where Command like "Sleep" and TIME >= "10"'| grep -v id); do /usr/bin/mysqladmin kill $requete ; done

Kill tous les selects de plus de 10s :

for requete in $(mysql INFORMATION_SCHEMA -B -e'select id from PROCESSLIST where INFO like "select%" and TIME >= "10"'| grep -v id); do /usr/bin/mysqladmin kill $requete ; done

Voir les requêtes en cours :

mysqladmin pro

ou

 mysql -e"show processlist"

Voir les requêtes en cours en entier :

 mysql -e"show full processlist"