Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had enabled MySQL Query Log for checking which queries are getting executed from our application at certain time interval.

I wanted Logs to be refreshed for 3 days once, So I had enabled Expiry Log days as 3 days.

But when I saw the log file, the log was there from the date of enabled the Query Log which was more than a week.

Due to this the log file got increased to more than 2 GB file which was not able to get the information from it.

Is there any option to enable so that Query Log file will be refreshed/purged after some days.

I am using MySQL 5.0.24 server.

share|improve this question
up vote 1 down vote accepted

expire_logs_days is responsible for rotating binary logs only.

You may need to zap the error log yourself.

Try doing this (Example : /var/log/mysqld.log is the error log)

Step 01) Create a script to copy the error log and gzip it, naming it by date and time (call the script /root/

cd /var/log
DT=`date +"%Y%m%d_%H%M%S"`
cat mysqld.log | gzip > ${BACKUP_ERROR_LOG}
echo -n > mysqld.log

Step 02) make /root/ executable

chmod +x /root/

Step 03) Add the script to the crontab (Rotate at midnight)

0 0 * * * /root/

Give it a Try !!!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.