[root@host-2 wj]# vi kill_tidb_zombie.sh #!/bin/bash source /etc/profile cat /dev/null > /tmp/sql_tmp_kill_zombie.sql kill_tidb_zom(){ #查询僵尸进程 mysql -h 192.168.1.$1 -P 4000 -u root -p'passwd' -e "select concat('kill tidb ',id,';') from INFORMATION_SCHEMA.processlist where info is not null and time > 7600;"|grep -v concat > /tmp/kill_tidb_zombie.tmp jg=$(cat /tmp/kill_tidb_zombie.tmp) #判断是否有僵尸进程 if [ -n "$jg" ] then cat /tmp/kill_tidb_zombie.tmp|while read -r line do echo "mysql -h 192.168.1.$1 -P 4000 -u root -p'passwd' -e \"$line\"" >> /tmp/sql_tmp_kill_zombie.sql done else echo 'null' fi } kill_tidb_zom 1 kill_tidb_zom 2 kill_tidb_zom 3 kill_tidb_zom 4 kill_tidb_zom 5 #执行杀掉僵尸进程的脚本 sh /tmp/sql_tmp_kill_zombie.sql