Shredder seems to hang

It has recently become clear that a script which calls rtx-shredder never finishes. It seems that shredder is actually hanging on something but I can’t figure out what. Script follows.



Version: 2.1.2

Author: Mathew Snyder

Date: August 5, 2007

Comments: A script to gather up the spam

sent to the Security queue and

eliminate the “users” that

created it. It then marks those

tickets as deleted for the purpose

of further housecleaning by the

rtx-shredder cronjob.

#Set up our environment
use warnings;
use strict;
use lib ‘/usr/local/rt3/lib’;
use lib ‘/usr/local/rt3/local/lib’;
use lib ‘/usr/local/lib’;
use RT;
use RT::Users;
use RT::Tickets;
use MIME::Lite;
use Reports::Emails;


my @usrID;
my %userID;
my @emails;
my %spammers;

my $users = new RT::Users(RT::SystemUser);

while ( my $user = $users->Next ) {
next if $user->Name eq ‘root’;
$skipEmails{$user->EmailAddress} = undef;

my $tix = new RT::Tickets(RT::SystemUser);
$tix->FromSQL(‘Queue = “zSPAM”’);

while (my $ticket = $tix->Next) {
if ($ticket->RequestorAddresses =~ /^$/ || $ticket->RequestorAddresses =~ /^$/) {
$ticket->DeleteWatcher (
Type => ‘Requestor’,
Email => $ticket->RequestorAddresses

$ticket->AddWatcher (

Type => ‘Requestor’,

Email => ‘’


    next if (exists($skipEmails{$ticket->RequestorAddresses}));
    $spammers{$ticket->RequestorAddresses} = undef;

push @emails, $ticket->RequestorAddresses;



my $count = 0;
#foreach my $email (@emails) {
foreach my $email (keys %spammers) {

system("/usr/local/rt3/local/sbin/rtx-shredder --force --plugin ‘Tickets=status,deleted;queue,zSPAM;limit,1000’ && rm -f /root/*.sql)";

my $emailTo = ‘’;
my $emailFrom = “RT”;
my $emailSubj = “RT Spam Removal”;
my $emailMsg = “The spam removal script has completed and has removed $count spam created users”;

my $fullEmail = new MIME::Lite(From => $emailFrom,
To => $emailTo,
Subject => $emailSubj,
Data => $emailMsg,

$fullEmail->send(“sendmail”, “/usr/sbin/sendmail -t”);

unlink glob “*.sql”;


There are likely some changes which I won’t be able to explain since they were made after I left the company. Admittedly, this is a poorly documented script which has left me scratching my own head wondering why I did things. Hopefully that won’t stop anyone from helping.

One thing that has been noticed is that there are two calls to rtx-shredder for each instance of the script. You’ll see that one is a system call (sh -c) and the other is a via perl (I’m guessing from the script itself)
Here is the ps output:
10013 pts/1 S 0:00 /usr/bin/perl /usr/local/sbin/
10014 pts/1 S 0:00 sh -c /usr/local/rt3/local/sbin/rtx-shredder
–force --plugin ‘Tickets=status,deleted;queue,zSPAM;limit,500’ && rm -f
10015 pts/1 S 0:31 /usr/bin/perl
/usr/local/rt3/local/sbin/rtx-shredder --force --plugin

In this output, I found that by killing process 10015 the other two terminated instantly. I’m guessing that when the system call is made perl is invoked again by way of rtx-shredder and 10015 reflect all the arguments passed. However, it never exits giving control back to the system call which would then, in turn, terminate giving control back to the script.

I haven’t seen any particular errors but then, I don’t know what they would look like. Anyone else run into a similar problem?

Keep up with my goings on at