Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

/var/spool/mqueue

SOLVED
Go to solution
Prakash1178
Advisor

/var/spool/mqueue

Hello,

My /var/spool/mqueue contaings approx 5 Lac files.

I want to remove these files but not possible in single shot of command " rm /var/spool/mqueue/*"

If I go for group of 50s files like " rm /var/spool/mqueue/TmAA* .... likewise... its happening...but will take few days /week this way.

Can you please suggest me how can i do this
can I remove complete directory "/var/spool/mqueue" by "rm -rf /var/spool/mqueue"

Regards,

Prakash
23 REPLIES
Jeeshan
Honored Contributor
Solution

Re: /var/spool/mqueue

Rasheed Tamton
Honored Contributor

Re: /var/spool/mqueue

Hi,

/var/spool/mqueue is the directory that mail spools in.

-fuser /var/spool/mqueue/
-stop sendmail (/sbin/init.d/sendmail stop)
-ll -d /var/spool/mqueue/ (note down the permissions)
-rm -rf /var/spool/mqueue/
(it will be faster to delete the dir and recreate it)

recreate the /var/spool/mqueue/ and give the correct permissions, restart the sendmail.

But you need to know and correct the problem of getting such a huge no. of mail queues. That should be the next step.

Regards,
Rasheed Tamton.





Prakash1178
Advisor

Re: /var/spool/mqueue

Hi,

I tried following loop on my server from the link suggested by you. But its giving message "sh:1: Paramenter not set.
-------------------------------------
for i in `mailq |grep -v Deferred |grep -v mqueue |grep -v - |awk '{print $1}'`
do
rm /var/spool/mqueue/df$i
rm /var/spool/mqueue/qf$i
done

# mailq
/var/spool/mqueue is empty
-----------------------------------

Regards,

Prakash
Rasheed Tamton
Honored Contributor

Re: /var/spool/mqueue

>My /var/spool/mqueue contaings approx 5 Lac files.
>If I go for group of 50s files like " rm /var/spool/mqueue/TmAA

With such a huge no. of queues and you were trying to remove it manually already, follow my steps for quick resolution.

Regards.
Prakash1178
Advisor

Re: /var/spool/mqueue

Hi Rasheed,

I felt better to go with your suggestion. Thanks to others for helping hands.

I have already launched "rm /var/spool/mqueue" and started clearing file.

But have lil question. If in case new created directory "/var/spool/mqueue" will miss by chance any right/owner/group, will it creat any major problem for my server functionality.

(FYI : We are not using mail services of our server at all.)

---------------------------------------------

fuser /var/spool/mqueue/
-stop sendmail (/sbin/init.d/sendmail stop)
-ll -d /var/spool/mqueue/ (note down the permissions)
-rm -rf /var/spool/mqueue/
(it will be faster to delete the dir and recreate it)

recreate the /var/spool/mqueue/ and give the correct permissions, restart the sendmail.
---------------------------------------------


Many thanks to All of you.

Reagards,

Prakash
Rasheed Tamton
Honored Contributor

Re: /var/spool/mqueue

Hi Prakash,
If you do not use mail then it will not affect it. But still it is better to mkdir and chown/mod again back for the above dir, if in case, someone else might use it in the future because the UNIX world supposed to be systematic and professional.

If you are new in the forum, please look assigning points section.

Regards,
Rasheed Tamton.
Jeeshan
Honored Contributor

Re: /var/spool/mqueue

hi agaian

almost similar thread from you. looks like the anser is here.
a warrior never quits
Dennis Handly
Acclaimed Contributor

Re: /var/spool/mqueue

>approx 5 Lac files.

How many is that again??

>Rasheed: (it will be faster to delete the dir and recreate it)

It would be faster to learn the right commands to remove massive quantities, so you don't mess up the directory permissions.
If you just want to remove all of them, you can do:
# find /var/spool/mqueue -type f -exec rm -f {} +

>But you need to know and correct the problem of getting such a huge no. of mail queues.'

Right.

>But its giving message "sh:1: Parameter not set.
for i in `mailq |grep -v Deferred |grep -v mqueue |grep -v - |awk '{print $1}'`

Something is wrong with this line. I have no idea why is it has "-v -"? I'll have to try this at work.

One way to check this is to execute:
mailq | grep -v Deferred | grep -v mqueue | grep -v - | awk '{print $1}'

You are probably getting nothing.

># mailq
/var/spool/mqueue is empty

Well you emptied the queue.

And look at your other thread as mentioned by Ahsan:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1230131

http://h30499.www3.hp.com/t5/Messaging/cleaning-var-spool-mqueue/m-p/5108075

Prakash1178
Advisor

Re: /var/spool/mqueue

Hello Dennis,

I found following message on executing your suggested ( If you just want to remove all of them, you can do:
# find /var/spool/mqueue -type f -exec rm -f +)

I found :
find: -exec not terminated with ";"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can yo uplease tell me what does it mean..

Regards,

Prakash
Dennis Handly
Acclaimed Contributor

Re: /var/spool/mqueue

># find /var/spool/mqueue -type f -exec rm -f +)
>I found: find: -exec not terminated with ";"
>Can you please tell me what does it mean?

Remove the extra ")" at the end of the line. (Or was that ")" just your quoting?)
The "+" acts like a ";" except it makes it work much faster.
If your find doesn't accept that "+", you must be on 10.20?

You could try: exec rm -f {} +
Prakash1178
Advisor

Re: /var/spool/mqueue

Dennis,

That ")" was not extracharacter... it was just completion of bracket.

My system is HP UX R 11i

I tried

-exec rm -f{}+

but is giving
find: -exec required an argument.
rm:illegal option --{
rm:illegal option --}
rm:illegal option --+

Regards,


Prakash
Prakash1178
Advisor

Re: /var/spool/mqueue

Dennis,

That ")" was not extracharacter... it was just completion of bracket.

My system is HP UX R 11i

I tried

-exec; rm -f{}+

but is giving
find: -exec required an argument.
rm:illegal option --{
rm:illegal option --}
rm:illegal option --+

Can I try
-exec; rm -f

Regards,


Prakash
Dennis Handly
Acclaimed Contributor

Re: /var/spool/mqueue

>-exec rm -f{}+
find: -exec required an argument.
rm:illegal option --{
rm:illegal option --}
rm:illegal option --+

You need to cut&paste, not retype, you are missing spaces:
-exec rm -f {} +
Rasheed Tamton
Honored Contributor

Re: /var/spool/mqueue

Hi Prakash,

In your case using find is not required at all. All the files in /var/spool/mqueue are normal files.

If you do not want to remove the dir, you can use:

cd /var/spool/mqueue
rm *


regards.
Yogeeraj_1
Honored Contributor

Re: /var/spool/mqueue

Dennis:
>>approx 5 Lac files.
>How many is that again??

I think Prakash is refering to 500,000 files.


Prakash:
Always be prudent when using the rm commands, if you miss something or have something extra, it can have dramatic consequences. If you unsure of the syntax, do a "man " on your system.

e.g. man find


kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Prakash1178
Advisor

Re: /var/spool/mqueue

Hi Dennis
~~~~~~~~~
You were right. I was missing spaces. Thanks for your suggestion. It worked and still in execution and removing files ( as I can see free space increasing in bdf ) I think It will take very long time, but ultimately will make few space on my server

Can I use this script in crontab for periodic cleaning of this directory ??

Hi Rasheed
~~~~~~~~~~~
cd /var/spool/mqueue
rm *
Is not workig and returing with message " too many files"

But your earlier suggestion really helped me clearing many MBs of space on my disc and after getting solution from Dennis I interrupted and started Dennis's solution to learn more.

Thanks anyways.

Yogiraj
~~~~~~~
Thanks for your valuable input. Infact i was also afriad of using diff syntax for rm but I cound not find good man for "rm".

I am really thankful to all of you.

Regards,

Prakash.

Yogeeraj_1
Honored Contributor

Re: /var/spool/mqueue

>Can I use this script in crontab for periodic cleaning of this directory ??

Of course you can create and schedule a maintenace script... But it would be wiser to find the source of the problem.

If you need any further assistance, please let us know.


>but I cound not find good man for "rm".
man rm
is already very informative and simple. :)


good luck!
kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Rasheed Tamton
Honored Contributor

Re: /var/spool/mqueue

Hi Prakash,

500 thousand files are too much. That is why I suggested rmving the dir. find normally consumes CPU, but it depends on your system.

Before you use rm, you always make sure that you are in the correct dir by using pwd command.

rm has -i option. But it is not good for using with many files.

man rm

Regards,
Rasheed Tamton.
Dennis Handly
Acclaimed Contributor

Re: /var/spool/mqueue

>Rasheed: In your case using find is not required at all.

You'll need to use find/ls if you have .5 million files. That "too many files" error.

>Can I use this script in crontab for periodic cleaning of this directory?

Sure. But why do you have so many files?
If you want to script it, you can add "-mtime +30" to remove files over 30 days old.

>Rasheed: That is why I suggested rmving the dir. find normally consumes CPU.

I would assume the cost would be the same with the find(1) only being a small cost of removing the files.
Fabien GUTIERREZ
Frequent Advisor

Re: /var/spool/mqueue

if you are able to stop sendmail service ie no applicative downtine by doing that and that u don't want to save the file just make
stop sendmail,umount FS and newfs on /var/spool/mqueue and u ll get rid of the files.
Dennis Handly
Acclaimed Contributor

Re: /var/spool/mqueue

Ok, I've decoded the following:
mailq | grep -v Deferred |grep -v mqueue | grep -v - |awk '{print $1}'

That "grep -v -" is the same as: grep -v -e -

This can all be replaced by:
mailq | awk 'substr($0,1,1) !~ "[\t -]" { print $1 }'

Of course this for loop won't work if there are that many files. You would have to change it to a while read:
mailq | awk 'substr($0,1,1) !~ "[\t -]" { print $1 }' | while read i; do
rm /var/spool/mqueue/?f$i
done
Prakash1178
Advisor

Re: /var/spool/mqueue

Dear Friends,

Finally I cleaned my server with the help of all of you.

I tried to give ratings on day berfore yesterday but due to some technical problems on site It was not processing. Yesterday I was unavailable & today its not giving me option to give ratings.

But if there any manual way to give ratings by writing I am giving ratings 10 to all ( Dennis, Rasheed, Fabin, Yogiraj )

Many thanks once again to all of you and all those who didnot contribut but even look at the problem and tried to give me solution.


Regards,

Prakash
Dennis Handly
Acclaimed Contributor

Re: /var/spool/mqueue

>Yesterday I was unavailable & today it's not giving me option to give ratings.

I can only request you be patient and try again. :-)

Since the thread isn't closed, it should allow you to assign points.
I've heard that if you try to assign points and close at the same time, the points are ignored, so try in two steps.

>But if there any manual way to give ratings by writing

Well, we thank you. But see if you can get the points to work, since they did initially.