Visit Our UNIX and Linux User Community


Clearing Mail Queue


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Clearing Mail Queue
# 1  
Old 05-18-2002
Clearing Mail Queue

Hello,

I am trying to clear my mail queue with the following command:
Code:
rm /var/spool/mqueue/*

But when I do this I get this error:
Code:
/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

Last edited by rbatte1; 11-17-2016 at 11:00 AM.. Reason: Added CODE tags
# 2  
Old 05-18-2002
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:
Code:
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...
Code:
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
Code:
/usr/lib/sendmail -q -v


Last edited by rbatte1; 11-17-2016 at 10:59 AM.. Reason: Added CODE tags
This User Gave Thanks to Perderabo For This Post:
# 3  
Old 05-18-2002
Quote:
But are sure that you want to do this? You are going to discard all of your mail!
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 Smilie
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #557
Difficulty: Easy
The most expert of software developers never make mistakes.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Printer queue not clearing

Hi I have installed an HP X451dw printer on our network and want to print from Sco Openserver v6 The printer produces correct output but then repeats until the queue is manually stopped. :confused: It is using a netcat/dumb interface Any advice on how to persuade it to only print once... (5 Replies)
Discussion started by: David Holmes
5 Replies

2. Shell Programming and Scripting

Check mail queue

We use Redhat server , we always use mailq to check any pending mail in mailq , when run the command mailq , it shows all existing pending mail would advise how to write a script to show the pending mails which are older than 24 hours , ( if possible , then send this pending mail info to... (9 Replies)
Discussion started by: ust3
9 Replies

3. Shell Programming and Scripting

Check pending mail in mail queue

I know the command mailq can check the pending mail in mqueue , and also have another command to check POSIX mail queue in server , now I will regularly check the mqueue manually , it is time consuming , would advise the script that could help to check the mail queue , and then send the details to... (3 Replies)
Discussion started by: ust3
3 Replies

4. UNIX for Dummies Questions & Answers

Mail Queue refilling

Hello I'm using Cent OS6 and a webmin interface I've had an issue where over 1 million emails were queued in the sendmail mail queue. I found a thread on here from 2002 explaining how to delete them all and it worked great. Thanks Perderabu unix-for-dummies-questions-and-answers /... (0 Replies)
Discussion started by: bullbreed
0 Replies

5. AIX

clearing PVID

HI admins, I am not able to clear pvid .I am getting below error. chdev -l hdisk273 -a pv=clear Method error (/usr/lib/methods/chgdisk): 0514-047 Cannot access a device. pv The disk is from SAN. I can clear remove the disk using rmdev.But if i run cfgmgr , this disk apperas... (2 Replies)
Discussion started by: newaix
2 Replies

6. Shell Programming and Scripting

flush the mail queue

Hi Guys, My mail queue is showing a mail. I want to flush the queue. Can you let me know how to flush the mail queue. Regards, Magesh (12 Replies)
Discussion started by: mac4rfree
12 Replies

7. IP Networking

postfix - reinject mail to postfix from hold queue directory

hi all. Am using smtpd_recipient_restrictions & check_recipient_access in postfix. The hash file looks like this: emailaddress1 HOLD emailaddress2 HOLD The aim is to place email from these recipients in the hold directory,check them then reinject them back in postfix on some... (0 Replies)
Discussion started by: coolatt
0 Replies

8. UNIX for Advanced & Expert Users

mail is not sent, instead just coping into /var/spool/queue dir

Hi, I have some problems w/ the sendmail. I see that messages are queued in the /var/spool/mqueue and they are never sent to the recipients. This problem just suddenly started without any modifications in the current configuration. I already started and stop the sendmail and it did not help.... (3 Replies)
Discussion started by: ktanya
3 Replies

9. Shell Programming and Scripting

shell script needed for mail queue notification

Hi shell experts, I would like to have a shell script running in a redhat server for monitoring the mailqueue status. I have already installed the qmHandle and I am using it to get a status of the mail queue in daily basis. I am executing the qmhandle in the cron. Now I am planning to execute... (10 Replies)
Discussion started by: Nightman
10 Replies

10. Shell Programming and Scripting

MyDoom in mail queue

Is there someone out there that has a script for cleaning up the mail queue after viruses such as MyDoom? (5 Replies)
Discussion started by: pmj1970
5 Replies

Featured Tech Videos