有时敞开了slow_log仍然不能找到mysql的问题所在,而又不能时刻在电脑前,来一个简略的cron,守时抓取processlist快照
比如中创立process权限的mysql用户”mysqluser”,暗码”mysqlpwd”,当show full processlist条数大于10时才会在途径中显现快照
创立文件cronprocesslist.sh,记住修正权限,否则无法履行.
chmod 777 cronprocesslist.sh
#!/bin/bash
[ $(/usr/local/bin/mysql -umysqluser -pmysqlpwd -h mysqlhost -e show full processlist | tee /pathto/plist-`date +%F-%H-%M-%S`.log | wc -l) -lt 10 ] rm /pathto/plist-`date +%F-%H-%M-%S`.log
cron中增加
*/1 * * * * /path/cronprocesslist.sh