首頁 >資料庫 >mysql教程 >Kill掉MySQL中所有sleep的client线程_MySQL

Kill掉MySQL中所有sleep的client线程_MySQL

WBOY
WBOY原創
2016-06-01 13:29:511048瀏覽

bitsCN.com

Kill掉MySQL中所有sleep的client线程

 

写了一个脚本,run这个脚本,就可以kill掉MySQL中所有sleep的client线程

vim killsleep.sh#It is used to kill processlist of mysql sleep#!/bin/shwhile :do  n=`mysqladmin processlist -uadmin -pxxxxx|grep -i sleep |wc -l`  date=`date +%Y%m%d/[%H:%M:%S]`  echo $n  if [ "$n" -gt 10 ]  then  for i in `mysqladmin processlist -uadmin -pxxxxxx|grep -i sleep |awk '{print $2}'`  do     mysqladmin -uadmin -pxxxx kill $i  done  echo "sleep is too many I killed it " >> /tmp/sleep.log  echo "$date : $n" >> /tmp/sleep.log  fi                 sleep 1done

 


bitsCN.com
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn