Search code examples
mysqlmy.cnfbinlog

Expire bin log in minutes


In the mysql conf file my.cnf, I want to add expiry time for the bin-logs. After doing a quick research on that, I got to know how to set it for days.i.e., expire_logs_days=3.

I want to set the expiry time for every 5 minutes. Is it possible ? How to do that ? I tried expire_logs_minutes=5, but that didn't work.

Thank for any help.


Solution

  • There is actually a way to archive your wanted behavior, but you have to implement this via a cron job or similar thing, just execute:

    PURGE BINARY LOGS BEFORE NOW() - INTERVAL 5 MINUTE;
    

    Above will remove your binlog-files older than five minutes. See also the documentation: PURGE BINARY LOGS Syntax