Created
October 26, 2012 02:23
-
-
Save fakechris/3956568 to your computer and use it in GitHub Desktop.
shared by meilishuo ppt in photo, type it by me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| port=$3 | |
| if [ $port'z' == 'z' ] | |
| then | |
| port=3306 | |
| fi | |
| mysql -h${1} -P${port} -e "select * from information_sechema.processlist where info is not null and time>${2} and user like '%dbreader%' and info like '%select%'\G">.sql.${1}.tmp | |
| pids=`mysql -h${1} -P${port} -e "select id from information_sechema.processlist where info is not null and time>${2} and user like '%dbreader%' and info like '%select%'"|awk -F\| '{print $1"\n"}'` | |
| if [ -s .sql.${1}.tmp ] | |
| then | |
| date +"%Y%M%D %H:%m:%s">>${1}_1.log | |
| cat .sql.${1}.tmp>>${1}_1.log | |
| fi | |
| for i in $pids" 0" | |
| do | |
| echo "${1}"; | |
| mysql -h${1} -P${port} -e "kill $i;" 1>/dev/null 2>/dev/null | |
| done | |
| echo -e "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment