View | Details | Raw Unified | Return to bug 8584
Collapse All | Expand All

(-)a/misc/cronjobs/cleanup_database.pl (-12 / +13 lines)
Lines 21-26 use strict; Link Here
21
use warnings;
21
use warnings;
22
22
23
use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30;
23
use constant DEFAULT_ZEBRAQ_PURGEDAYS => 30;
24
use constant DEFAULT_MAIL_PURGEDAYS => 30;
24
use constant DEFAULT_IMPORT_PURGEDAYS => 60;
25
use constant DEFAULT_IMPORT_PURGEDAYS => 60;
25
use constant DEFAULT_LOGS_PURGEDAYS => 180;
26
use constant DEFAULT_LOGS_PURGEDAYS => 180;
26
27
Lines 49-55 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
49
                      about the run.
50
                      about the run.
50
   --zebraqueue DAYS  purge completed zebraqueue entries older than DAYS days.
51
   --zebraqueue DAYS  purge completed zebraqueue entries older than DAYS days.
51
                      Defaults to 30 days if no days specified.
52
                      Defaults to 30 days if no days specified.
52
   -m --mail          purge the mail queue. 
53
   -m --mail DAYS     purge items from the mail queue that are older than DAYS days.
54
                      Defaults to 30 days if no days specified.
53
   --merged           purged completed entries from need_merge_authorities.
55
   --merged           purged completed entries from need_merge_authorities.
54
   --import DAYS      purge records from import tables older than DAYS days.
56
   --import DAYS      purge records from import tables older than DAYS days.
55
                      Defaults to 60 days if no days specified.
57
                      Defaults to 60 days if no days specified.
Lines 66-72 GetOptions( Link Here
66
    'sessions'     => \$sessions,
68
    'sessions'     => \$sessions,
67
    'sessdays:i'   => \$sess_days,
69
    'sessdays:i'   => \$sess_days,
68
    'v|verbose'    => \$verbose,
70
    'v|verbose'    => \$verbose,
69
    'm|mail'       => \$mail,
71
    'm|mail:i'       => \$mail,
70
    'zebraqueue:i' => \$zebraqueue_days,
72
    'zebraqueue:i' => \$zebraqueue_days,
71
    'merged'       => \$purge_merged,
73
    'merged'       => \$purge_merged,
72
    'import:i'     => \$pImport,
74
    'import:i'     => \$pImport,
Lines 79-84 $sessions=1 if $sess_days && $sess_days>0; Link Here
79
$pImport= DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport==0;
81
$pImport= DEFAULT_IMPORT_PURGEDAYS if defined($pImport) && $pImport==0;
80
$pLogs= DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs==0;
82
$pLogs= DEFAULT_LOGS_PURGEDAYS if defined($pLogs) && $pLogs==0;
81
$zebraqueue_days= DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days==0;
83
$zebraqueue_days= DEFAULT_ZEBRAQ_PURGEDAYS if defined($zebraqueue_days) && $zebraqueue_days==0;
84
$mail= DEFAULT_MAIL_PURGEDAYS if defined($mail) && $mail==0;
82
85
83
if ($help) {
86
if ($help) {
84
    usage(0);
87
    usage(0);
Lines 139-153 if ($zebraqueue_days) { Link Here
139
}
142
}
140
143
141
if ($mail) {
144
if ($mail) {
142
    if ($verbose) {
145
    print "Mail queue purge triggered for $mail days.\n" if ($verbose);
143
        $sth = $dbh->prepare("SELECT COUNT(*) FROM message_queue");
146
144
        $sth->execute() or die $dbh->errstr;
147
    $sth = $dbh->prepare("DELETE FROM message_queue WHERE time_queued < date_sub(curdate(), interval ? day)");
145
        my @count_arr = $sth->fetchrow_array;
148
    $sth->execute($mail) or die $dbh->errstr;
146
        print "Deleting $count_arr[0] entries from the mail queue.\n";
149
    my $count = $sth->rows;
147
    }
150
    $sth->finish;
148
    $sth = $dbh->prepare("TRUNCATE message_queue");
151
149
    $sth->execute() or $dbh->errstr;
152
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if ($verbose);
150
    print "Done with purging the mail queue.\n" if ($verbose);
151
}
153
}
152
154
153
if($purge_merged) {
155
if($purge_merged) {
154
- 

Return to bug 8584