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

(-)a/misc/cronjobs/cleanup_database.pl (-5 / +14 lines)
Lines 38-45 use Getopt::Long; Link Here
38
38
39
sub usage {
39
sub usage {
40
    print STDERR <<USAGE;
40
    print STDERR <<USAGE;
41
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS]
41
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged]
42
        [-m|--mail]
42
43
   -h --help          prints this help message, and exits, ignoring all
43
   -h --help          prints this help message, and exits, ignoring all
44
                      other options
44
                      other options
45
   --sessions         purge the sessions table.  If you use this while users 
45
   --sessions         purge the sessions table.  If you use this while users 
Lines 50-60 Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueu Link Here
50
   --zebraqueue DAYS  purge completed entries from the zebraqueue from 
50
   --zebraqueue DAYS  purge completed entries from the zebraqueue from 
51
                      more than DAYS days ago.
51
                      more than DAYS days ago.
52
   -m --mail          purge the mail queue. 
52
   -m --mail          purge the mail queue. 
53
   --merged           purged completed entries from need_merge_authorities.
53
USAGE
54
USAGE
54
    exit $_[0];
55
    exit $_[0];
55
}
56
}
56
57
57
my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail );
58
my ( $help, $sessions, $sess_days, $verbose, $zebraqueue_days, $mail, $purge_merged);
58
59
59
GetOptions(
60
GetOptions(
60
    'h|help'       => \$help,
61
    'h|help'       => \$help,
Lines 63-75 GetOptions( Link Here
63
    'v|verbose'    => \$verbose,
64
    'v|verbose'    => \$verbose,
64
    'm|mail'       => \$mail,
65
    'm|mail'       => \$mail,
65
    'zebraqueue:i' => \$zebraqueue_days,
66
    'zebraqueue:i' => \$zebraqueue_days,
67
    'merged'       => \$purge_merged,
66
) || usage(1);
68
) || usage(1);
67
69
68
if ($help) {
70
if ($help) {
69
    usage(0);
71
    usage(0);
70
}
72
}
71
73
72
if ( !( $sessions || $zebraqueue_days || $mail ) ) {
74
if ( !( $sessions || $zebraqueue_days || $mail || $purge_merged) ) {
73
    print "You did not specify any cleanup work for the script to do.\n\n";
75
    print "You did not specify any cleanup work for the script to do.\n\n";
74
    usage(1);
76
    usage(1);
75
}
77
}
Lines 134-139 if ($mail) { Link Here
134
    $sth->execute() or $dbh->errstr;
136
    $sth->execute() or $dbh->errstr;
135
    print "Done with purging the mail queue.\n" if ($verbose);
137
    print "Done with purging the mail queue.\n" if ($verbose);
136
}
138
}
139
140
if($purge_merged) {
141
    print "Purging completed entries from need_merge_authorities.\n" if $verbose;
142
    $sth = $dbh->prepare("DELETE FROM need_merge_authorities WHERE done=1");
143
    $sth->execute() or die $dbh->errstr;
144
    print "Done with purging need_merge_authorities.\n" if $verbose;
145
}
146
137
exit(0);
147
exit(0);
138
148
139
sub RemoveOldSessions {
149
sub RemoveOldSessions {
140
- 

Return to bug 6094