Clearing Mail Queue

Hello,

I am trying to clear my mail queue with the following command:

rm /var/spool/mqueue/*

But when I do this I get this error:

/bin/rm: Argument list too long.

Can someone tell me what that error means and what I can do to correct it so I can clear my mail queue?

Thanks

The shell expands that * into a list of filenames and then tries to run the rm command with that list. But there's a limit to how long that list can be and you exceeded it.

Since you are using the full path, you might try a relative path instead:

cd /var/spool/mqueue
rm *

Now each individual file no longer has the /var/spool/mqueue/ prefix so the expanded command is much shorter. But if this is still too long, you can try this...

cd /var/spool/mqueue
ls | xargs rm

The ls produces a list of file names which xargs reads. It then assembles them into a bunch of rm commands. It knows how long each one can be and it won't assemble a command that is too long.

But are sure that you want to do this? You are going to discard all of your mail! My idea of clearing the queue is

/usr/lib/sendmail -q -v

Yes I am sure...I made a script to email all of my 2,000 members but I forgot to put in the "from" part so my mail queue was filling up with error messages. The queue was over 2.5 MB at one point.

I got this problem solved though...
Thank You :smiley: