You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For 5.1 and above when slow_query_log_file is a dynamic variable
file: start_queries_capture.sh
#!/bin/bash
mysql -e "set global slow_query_log_file='/var/log/mysql/slow_query_capture.log'"
mysql -e "set global long_query_time=0"
mysqladmin flush-logs
file: stop_queries_capture.sh
#!/bin/bash
mysql -e "set global long_query_time=10"
mysql -e "set global slow_query_log_file='/var/log/mysql/slow_query.log'"
mysqladmin flush-logs
mv /var/log/mysql/slow_query_capture.log /root/percona/
For 5.0 and below when slow query log filename cannot be changed
file: start_queries_capture.sh
#!/bin/bash
mv /data/mysql/log-slow-mysql /data/mysql/log-slow-mysql.bak
mysqladmin flush-logs
mysql -e "set global long_query_time=0"
file: stop_queries_capture.sh
#!/bin/bash
mysql -e "set global long_query_time=2"
mv /data/mysql/log-slow-mysql /root/percona/
mv /data/mysql/log-slow-mysql.bak /data/mysql/log-slow-mysql
mysqladmin flush-logs
create required directory and create the files as above
mkdir /root/percona
schedule the job such that query capture starts at 9am and ends at 10am
at -f /root/percona/start_queries_capture.sh -v 09:00
at -f /root/percona/stop_queries_capture.sh -v 10:00