On Thu, Jun 06, 2002 at 10:03:54AM -0400, Dave Swindell wrote: > What I'd like to do is to set up a mechanism where every week I > rotate my replication log files and delete (or archive) the ones I > no longer need. Can anyone point me to some docs where I can learn > how to do this?
Here's the Perl script we use... ---snip--- #!/usr/local/bin/perl -w # # $Source: /CVSROOT/yahoo/finance/mysql/bin/purge_binary_logs,v $ ## On a mysql server, purge the replication logs if there are "too ## many" sitting around and sucking up disk space. $|++; use strict; use RunMutex '/tmp/.write_heartbeat.lock'; use DBIx::DWIW; my $MIN_LOGS = 7; ## keep at least three binary logs around my $db = DBIx::DWIW->Connect( DB => "mysql", User => "root", Pass => "secret", Host => 'localhost', ); if (not $db) { die "Couldn't connect to database!"; } my @logs = $db->FlatArray("SHOW MASTER LOGS"); ## see if there are enough to bother if (@logs < $MIN_LOGS) { exit; } ## if so, figure out what the last one we want to kee is my $last_log = $logs[-$MIN_LOGS]; print "last log is $last_log\n" unless $ENV{CRON}; ## and purge the rest $db->Execute("PURGE MASTER LOGS TO '$last_log'"); exit; __END__ ---snip--- HTH, Jeremy -- Jeremy D. Zawodny, <[EMAIL PROTECTED]> Technical Yahoo - Yahoo Finance Desk: (408) 349-7878 Fax: (408) 349-5454 Cell: (408) 685-5936 MySQL 3.23.51: up 8 days, processed 192,694,624 queries (270/sec. avg) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php