# When is bin-logs expired by expire\_log\_days?

**URL:** <https://forums.percona.com/t/when-is-bin-logs-expired-by-expire-log-days/3503>\
**Category:** Other MySQL® Questions\
**Created:** [May 27, 2014, 6:16am UTC](https://forums.percona.com/t/when-is-bin-logs-expired-by-expire-log-days/3503 "2014-05-27T06:16:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigurdur](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sigurdur](https://forums.percona.com/u/sigurdur)\
**Post date:** [May 27, 2014, 6:16am UTC](https://forums.percona.com/t/when-is-bin-logs-expired-by-expire-log-days/3503/1 "2014-05-27T06:16:07Z")

</div>

I have Percona 5.5.25 server running with binlogging, no slaves, and a high change rate (~100GB binlogs/day, 1 to 6 GB/hour varying through the day).

The server is configured with expire\_log\_days=2 and max\_binlog\_size=1G.

I expected to see old binlogs be removed more or less in sync with new binlogs being created, but it seems the expiry happens only around four times a day, but not in strictly regular intervals. See the attached graph showing disk usage for the directory containing the binlogs.

Is this a bug or feature, or an artifact of something in my Mysql server that I fail to see? I see that I can work around this by implementing expiry through external cronbased purging, but it would be nice to keep the log handeling interal in Mysql.

kind regards,  
-sigurd

![photoid=15545|attachment](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/7/795d6e3354f918739c17a3074a63c9dbe615cd16.png)

---

<div class="post-metadata">

**Author:** ![mirfan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/mirfan/32/16890_2.png) [@mirfan](https://forums.percona.com/u/mirfan)\
**Post date:** [May 28, 2014, 9:45pm UTC](https://forums.percona.com/t/when-is-bin-logs-expired-by-expire-log-days/3503/2 "2014-05-28T21:45:53Z")

</div>

expire\_log\_days takes into effect in two situations.

1. During server startup if expire\_log\_days reached to it’s value.
2. During log flush if expire\_log\_days reached to it’s value.

So, when log flushes it expires logs older than 48 hours as you set expire\_log\_days=2, check here for details [url][MySQL :: MySQL 5.6 Reference Manual :: 5.1.7 Server System Variables](http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_expire_logs_days%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![sigurdur](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@sigurdur](https://forums.percona.com/u/sigurdur)\
**Post date:** [May 30, 2014, 4:10am UTC](https://forums.percona.com/t/when-is-bin-logs-expired-by-expire-log-days/3503/3 "2014-05-30T04:10:22Z")

</div>

The next question then is when are logs flushed?

I know the binlog is flushed when it reaches max\_binlog\_size, which happens 1 to 6 times an hour on this system. But the flush that expires logs seems to happen only around four times a day, and not at the regualr intervals.
