欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

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

程序员文章站 2022-06-02 08:01:06
...
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
相关标签: sleep