?
#! /bin/sh
#
# clear_sleep.sh
# Copyright (C) 2015 root <[email protected]>
#
# Distributed under terms of the MIT license.
#
mysql -u root -p123456 -e "SET GLOBAL group_concat_max_len=102400;"
mysql -u root -p123456 -e "select
case count(1)>50
when true
then
(select group_concat(concat('KILL ',id,';') separator '') from information_schema.processlist where Command = 'Sleep' AND user = 'root' and host!='localhost')
else ''
end
from information_schema.processlist where Command = 'Sleep' AND user = 'root' and host!='localhost'
into outfile '/tmp/sleep_processes.txt'"
mysql -u root -p123456 -e "source /tmp/sleep_processes.txt;"
rm -rf /tmp/sleep_processes.txt
#
# clear_sleep.sh
# Copyright (C) 2015 root <[email protected]>
#
# Distributed under terms of the MIT license.
#
mysql -u root -p123456 -e "SET GLOBAL group_concat_max_len=102400;"
mysql -u root -p123456 -e "select
case count(1)>50
when true
then
(select group_concat(concat('KILL ',id,';') separator '') from information_schema.processlist where Command = 'Sleep' AND user = 'root' and host!='localhost')
else ''
end
from information_schema.processlist where Command = 'Sleep' AND user = 'root' and host!='localhost'
into outfile '/tmp/sleep_processes.txt'"
mysql -u root -p123456 -e "source /tmp/sleep_processes.txt;"
rm -rf /tmp/sleep_processes.txt
?