系统相关
首页 > 系统相关> > tidb自动处理僵尸进程脚本

tidb自动处理僵尸进程脚本

作者:互联网

[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

  

标签:脚本,tmp,僵尸,sql,zom,zombie,kill,tidb
来源: https://www.cnblogs.com/wukc/p/16561209.html