The execution of show processlist in Mysql shows many Sleep threads. Due to Program Design Bugs, there are many Sleep threads in the database currently used in this project. I have found many solutions and have not found any final solutions. You can only use the following method temporarily: Write a shell file, such as killSleepProcess. sh.
[Plain] while: do n = 'mysqladmin-uroot-p *** processlist | grep-I sleep | wc-l 'date = 'date + % Y % m % d \ [% H: % M: % S] 'echo $ n if ["$ n"-gt 10] then for I in 'mysqladmin-uroot-p *** processlist | grep-I sleep | awk '{ print $2} ''do mysqladmin-uroot-p *** kill $ I done echo "sleep is too I killed it">/root/tmp/sleep. log echo "$ date: $ n" >>/ root/tmp/sleep. log fi sleep 120 # Run done once every 120 seconds
The result of the above shell code is: kill all the threads in the Sleep state queried by show processlist.