文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学的各位小编整理了MySQL-杀mysql sleep 进程的脚本的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
#It is used to kill processlist of mysql sleep~~~ #!/bin/sh while : do n=`/opt/mysql/bin/mysqladmin processlist|grep -i sleep |wc -l` date=`date +%Y%m%d[%H:%M:%S]` echo $n # id=`/opt/mysql/bin/mysqladmin processlist |grep Sleep |awk '{if ($12 gt; 100) {print $2}}'` # echo quot;$date : $n quot; gt; gt; /tmp/sleep.log # if [ id != quot; quot; ] # then # for j in $id # do # /opt/mysql/bin/mysqladmin kill $j # echo quot;$date : sleep is to long quot; gt; gt; /tmp/sleep.log # fi # if [ quot;$n quot; -gt 60 ] then for i in `/opt/mysql/bin/mysqladmin processlist|grep -i sleep |awk '{print $2}'` do /opt/mysql/bin/mysqladmin kill $i done echo quot;sleep is too many i killed it quot; gt; gt; /tmp/sleep.log echo quot;$date : $n quot; gt; gt; /tmp/sleep.log fi sleep 1 done