Shell Script to auto kill mysql sleep processes

后端 未结 5 759
别跟我提以往
别跟我提以往 2021-02-07 19:29

How We Kill mysql sleep processes Like:

+------+-----------+-----------+------------------------+---------+------+----------------+-----------------------------------         


        
5条回答
  •  故里飘歌
    2021-02-07 19:56

    The syntax is:

    KILL thread_id
    

    In your case:

      mysql > KILL 3057
    

    But in order to delete all the sleep processes,one command cant be used, you need to loop through whole processlist,after taking all the processes in tmp table and looping through it:

    select concat('KILL ',id,';') from information_schema.processlist where Command='Sleep';
    
    select concat('KILL ',id,';') from information_schema.processlist where Command='Sleep' into outfile '/tmp/a.txt';
    

    Referred from here

提交回复
热议问题