Bugzilla – Attachment 11394 Details for
Bug 8584
Improve cleanup_database.pl to only purge emails older than X days.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
cleanup_database.pl : Add a DAYS parameter for email purges.
0001-cleanup_database.pl-Add-a-DAYS-parameter-for-email-p.patch (text/plain), 3.17 KB, created by
Frédérick Capovilla
on 2012-08-06 21:05:59 UTC
(
hide
)
Description:
cleanup_database.pl : Add a DAYS parameter for email purges.
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2012-08-06 21:05:59 UTC
Size:
3.17 KB
patch
obsolete
>From 946ea87b2a7efa4aaddffb387e6d828d2b1a49a7 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick=20Capovilla?= <frederick.capovilla@libeo.com> >Date: Mon, 21 Nov 2011 15:33:23 -0500 >Subject: [PATCH] cleanup_database.pl : Add a DAYS parameter for email purges. > >You can now specify a number of DAYS with the --mail parameter. Only >mails older than DAYS days will be deleted. >--- > misc/cronjobs/cleanup_database.pl | 24 +++++++++++++----------- > 1 files changed, 13 insertions(+), 11 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 99310df..4b6444f 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -21,6 +21,7 @@ use strict; > use warnings; > > use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30; >+use constant DEFAULT_MAIL_PURGEDAYS => 30; > use constant DEFAULT_IMPORT_PURGEDAYS => 60; > use constant DEFAULT_LOGS_PURGEDAYS => 180; > >@@ -49,7 +50,8 @@ Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu > about the run. > --zebraqueue DAYS purge completed zebraqueue entries older than DAYS days. > Defaults to 30 days if no days specified. >- -m --mail purge the mail queue. >+ -m --mail DAYS purge items from the mail queue that are older than DAYS days. >+ Defaults to 30 days if no days specified. > --merged purged completed entries from need_merge_authorities. > --import DAYS purge records from import tables older than DAYS days. > Defaults to 60 days if no days specified. >@@ -66,7 +68,7 @@ GetOptions( > 'sessions' => \$sessions, > 'sessdays:i' => \$sess_days, > 'v|verbose' => \$verbose, >- 'm|mail' => \$mail, >+ 'm|mail:i' => \$mail, > 'zebraqueue:i' => \$zebraqueue_days, > 'merged' => \$purge_merged, > 'import:i' => \$pImport, >@@ -79,6 +81,7 @@ $sessions=1 if $sess_days && $sess_days>0; > $pImport= DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport==0; > $pLogs= DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs==0; > $zebraqueue_days= DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days==0; >+$mail= DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail==0; > > if ($help) { > usage(0); >@@ -139,15 +142,14 @@ if ($zebraqueue_days) { > } > > if ($mail) { >- if ($verbose) { >- $sth = $dbh->prepare("SELECT COUNT(*) FROM message_queue"); >- $sth->execute() or die $dbh->errstr; >- my @count_arr = $sth->fetchrow_array; >- print "Deleting $count_arr[0] entries from the mail queue.\n"; >- } >- $sth = $dbh->prepare("TRUNCATE message_queue"); >- $sth->execute() or $dbh->errstr; >- print "Done with purging the mail queue.\n" if ($verbose); >+ print "Mail queue purge triggered for $mail days.\n" if ($verbose); >+ >+ $sth = $dbh->prepare("DELETE FROM message_queue WHERE time_queued < date_sub(curdate(), interval ? day)"); >+ $sth->execute($mail) or die $dbh->errstr; >+ my $count = $sth->rows; >+ $sth->finish; >+ >+ print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if ($verbose); > } > > if($purge_merged) { >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8584
:
11394
|
17396
|
18663