#!/usr/bin/env bash
mysql --login-path=test -e "show full processlist" | grep -i select | awk '{print $1,$6}' > /script/slow.txt

while read line
do
   time1=$(echo $line | awk '{print $2}')
   if [ $time1 -gt 5  ];then    超过5s杀掉
       id=$(echo $line | awk '{print $1}')
       echo $id, $time1
       mysql --login-path=test -e "kill $id"
   fi
done < /script/slow.txt

results matching ""

    No results matching ""