MySQL uses the so called binary log files to implement master/slaves replication.
You can set the expire_logs_days variable in your my.cnf file, which will set the number of days MySQL will keep those binary log files.
This is the longest time a MySQL replication slave can lag behind the master. If for a reason the slave is not able to replicate for more than this duration, then it won’t be able to catch back (you will have to get back data from the server one way or another)
To clean the binary log files you can use the “PURGE MASTER LOGS” SQL command which can delete binary logs before a specified date or till a specified binary log file.
To see the binary log files on the server, you can use the “SHOW BINARY LOGS” SQL command.
At last, to know up to which file you could delete the binary log files, you can run the “SHOW SLAVE STATUS” on each replication slave to see which binary log file they are using, and delete up to the oldest of them.