Kill all mysql threads that have 300 or more seconds of time:
mysqladmin -uroot processlist | grep -v +| awk –field-separator=’|’ {’ if ($7 > 500) print ” mysqladmin -uroot kill ” $2 ‘}
One quick note, need to check to see what status the connection is in, sleeping if you want to kill idle connections, or something else.
mysqladmin -uroot processlist | grep -v +| grep Sleep | awk –field-separator=’|’ {’ if ($7 > 500) print ” mysqladmin -uroot kill ” $2 ‘}