mysql 批量杀进程脚本

2018-03-22

批量杀死Sleep状态的进程
/data/backup/scripts/kill_sleep.sh
#kill_sleep.sh
#mysql批量杀死sleep进程
#!/bin/bash
source /etc/profile
source /root/.bash_profile
MYSQL_OPT="mysql --login-path=my3306"
DIR="/tmp"
$MYSQL_OPT -e "show processlist;"|awk '{print $1,$5}'|grep 'Sleep'|awk '{print "kill",$1";"}' >$DIR/sleep_pid.log
$MYSQL_OPT -e "source $DIR/sleep_pid.log;"
exit 0
 
批量杀死Sending data状态的进程
/data/backup/scripts/kill_send.sh
#kill_send.sh
#mysql批量杀死sending data进程
#!/bin/bash
source /etc/profile
source /root/.bash_profile
MYSQL_OPT="mysql --login-path=my3306"
DIR="/tmp"
$MYSQL_OPT -e "show processlist;"|awk '{print $1,$5,$7}'|grep "Sending"|awk '{print "kill",$1";"}'>$DIR/send_pid.log
$MYSQL_OPT -e "source $DIR/send_pid.log;"
exit 0
原文地址:https://www.cnblogs.com/cenliang/p/8627045.html