Shell Script to auto kill mysql sleep processes

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

How We Kill mysql sleep processes Like:

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


        
5条回答
  •  半阙折子戏
    2021-02-07 19:42

    Percona Tools:

    pt-kill --match-command Sleep --idle-time 100 --victims all  --interval 30 --kill
    

    This will find all connections that are "Sleep" state and idle for 100 seconds or more and kill them. --interval 30 will make it keep do this every 30 seconds. So you can open a screen -S ptkill then in that screen run the above command, then ctrl-A, D to detach and exit the terminal and it will just keep running cleaning up your connections.

    https://www.percona.com/doc/percona-toolkit/2.1/pt-kill.html

提交回复
热议问题