Disk Space Consumption due to SendMail service at /var

 Disk Space Consumption due to SendMail service at "/var"


This is service which sends mail. So when a linux server does not allow sendmail port out but the service is running.. it will cause all the mail is in queue at the /var/spool/clientmqueue/..

due the mail cannot send out.. When left it like this all the time. It will consume a large hard disk space..

At my server we have 20GB of space in "/var" and this sendmail service consumed whole space.
What I found that, it consumed my 4GB of space within 8 hours. I got shocked any this disk space consumption results in very strange behaviour on my service because they are dealing with files from /var. 

Trial ONE : When I run df -h, inside the /var/spool/clientmqueue/ my system stop responding because there are millions of mail files are avaialble in that folder which were creating problem to show their size.(Same thing can happen in windows, if you have hundreds of small files in a directory you just start browing then in window, it won't give you results, it will get hang).

Trial TWO : When I run ls -lrth | wc -l  to find the total number of files available in the directory, then again same thing observed. SYSTEM HANG  and no result for the command for next 1hours. 

Trial THREE : When i run rm -rf *  to delete all the files in the directory, then received failure to delete the files from the directory. System give a "argument list too long error will appear" as return gift.

It is totally waste of time..

Solution : After doing  lot of Google , I found the solution for the problem designed by myself. First time found no solution on Google.
I made a script by my own which really works. See what I've made, a simple sh script and it is as follow

#/bin/sh
for i in 1000 900 800 700
do
     find /var/spool/clientmqueue -ctime +i -exec rm -rf {} \;
done

This script will run and delete all the files created older then 1000 days then on next iteration it will delete files older then 900 and so on.....
What I can suggest for you, to keep the first day limit much higher based on observation of up time of your server.
End limit, keep as much as older data you want you delete.

In this way, you will be able to delete all unwanted mail queued files without any heavy band on the server CPU and Memory because find command is very light and fast.

So keep this for your future and Like post to spread solutions to others.

***************************************************************
Like the post and choose Follow and stay tuned for more updates.
JUST BELIEVE IN TECHNOLOGY..... Enjoy....

Comments

Popular Posts