Rotation of bin.log file I am trying to change the binary log rotation from days to hours. By default there is an option only for days in the MySQL config file: expire_logs_days.

Is there any way to change the binary log rotation from days to hours or even minutes?

I am running MySQL version 5.7.23 on Ubuntu 16.04.
The only way to get binlog rotation in hours is to script it

Here is the code

#!/bin/bash
HRS=16
mysql -uroot -prootpass -e"PURGE BINARY LOGS BEFORE NOW() - INTERVAL ${HRS} HOUR"


Put this code in a script called /root/mybinlog_rotate.sh

Make sure you run chmod +x /root/mybinlog_rotate.sh

Add that script in the crontab to rotate every 30 min

0,30 * * * * /root/mybinlog_rotate.sh


This is a little heavy handed but it can be done

I suggested this months ago : Maximum overall size of MariaDB binary logs