mysql批量kill sleep进程脚本

上一篇 / 下一篇  2019-09-10 15:00:21 / 个人分类:mysql

#!/bin/sh
while :
do
  p=iskyhadoop
  n=`mysqladmin processlist -uroot -p$p|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 -uroot -p$p|grep -i sleep |awk '{print $2}'`
  do
     mysqladmin -uroot -p$p kill $i
     echo  $i "is killed"
  done
  echo "sleep is too many I killed it " >> /opt/test/sleep.log
  echo "$date : $n" >> /opt/test/sleep.log
  fi
  sleep 1
done

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar