[rt-users] Emptying queue

amit poddar amit.poddar at yale.edu
Mon Apr 26 16:30:21 EDT 2004


Try this


#!/usr/bin/perl -w

use strict;
use Carp;
use Getopt::Long;

use lib '/u01/rt/rt/lib';
use lib '/u01/rt/rt/etc';

use RT::Interface::CLI  qw(CleanEnv GetCurrentUser GetMessageContent loc);
CleanEnv();

use RT;
use RT::Tickets;

RT::LoadConfig();

RT::Init();

#Get the current user all loaded
my $queue = shift;

my $Tickets = new RT::Tickets($RT::SystemUser);
$Tickets->LimitWatcher(TYPE => 'Queue', VALUE => $queue);
$Tickets->LimitStatus(VALUE => 'Deleted', OPERATOR => '!=');

unless ($Tickets->Count)
{
    print "tickets not found with queue $queue\n";
}
print "Amount of tickets requested by $queue is ".$Tickets->Count."\n";

while (my $t=$Tickets->Next)
{
    print "Ticket ID: " . $t->Id . "\n";

    my ($val,$msg) = $t->Delete();
    if ($val)
    {
       print "OK: $msg\n";
    }
    else
    {
       die "$msg";
    }
}

$RT::Handle->Disconnect();

Suppose this is saved is x.pl

Then you would execute

perl x.pl <queue_name>

amit


At 05:08 PM 4/26/2004 -0300, Garak wrote:

>Hello !
>
>I need delete all messages inside an certain queue.
>Exists some command line for this?
>
>Thank you!
>
>--
>Garak <garak at bol.com.br>
>
>_______________________________________________
>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
>RT Developer and Administrator training is coming to LA, DC and Frankfurt 
>this spring and summer.
>http://bestpractical.com/services/training.html
>
>Sign up early, as class space is limited.




More information about the rt-users mailing list