解决Mysql锁表进程Bash脚本
数据库偶尔会响应很慢,看着好像挂掉了,检查进程发现有大量查询语句把表锁住了,提供一个脚本给大家解决锁表导致的Mysql异常。
#!/bin/sh while : do n=`/usr/local/webserver/mysql/bin/mysql -uroot -p"kk41-,dnkkedkd8>/ee" -e 'show processlist;' | grep -i locked |grep -i search_keyword | wc -l` date=`date +%Y%m%d[%H:%M:%S]` echo $n if [ "$n" -gt 50 ] then for i in `/usr/local/webserver/mysql/bin/mysql -uroot -p"kk41-,dnkkedkd8>/ee" processlist | grep -i locked |grep -i search_keyword | awk '{print $2}'` do /usr/local/webserver/mysql/bin/mysql -uroot -p"kk41-,dnkkedkd8>/ee" kill $i done echo "killed it" >> /tmp/sleep.log echo "$date : $n" >> /tmp/sleep.log fi sleep 10 done以上转自:http://www.604f.com/read.php?5
相关推荐
emmm00 2020-11-17
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
疯狂老司机 2020-09-08
CoderToy 2020-11-16
ribavnu 2020-11-16
bianruifeng 2020-11-16