Home > Database > Mysql Tutorial > body text

Kill all sleeping client threads in MySQL

黄舟
Release: 2017-02-17 11:42:31
Original
1255 people have browsed it

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

#It is used to kill processlist of mysql sleep

#!/bin/sh
while :

do
  n=`mysqladmin processlist -uadmin -pxxxxx|grep -i sleep |wc -l`
  date=`date +%Y%m%d\[%H:%M:%S]`
  echo $n
Copy after login
 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 1
done
Copy after login

 以上就是Kill掉MySQL中所有sleep的client线程的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)! 


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!