[CentOS] Antwort: Re: what is the best way to delete so many queue files?

Frank.Brodbeck at klingel.de

Frank.Brodbeck at klingel.de
Tue Sep 1 07:12:35 UTC 2009


Hi,

"nate" <centos at linuxpowered.net> schrieb am 31.08.2009 23:57:09:

> MontyRee wrote:
> 
> > What is the best way to delete fast without too much load?
> 
> If you put /var on another file system you could:
> - go to single user mode
> - copy all files off of /var except those in the queue directory
> - re-format the file system
> - copy all the files back
> - go to multi user mode
> 
> If there are a TON of files that could be much much faster
> than deleting them individually.
> 
> otherwise:
> 
> find /var/spool/clientmqueue -type f -exec rm -f {} \;

You probably want to do

find /var/spool/clientmqueue -type f -exec rm -f {} \+

to reduce your load or if your find(1) isn't POSIX compliant:

find /var/spool/clientmqueue -type f -print0 | xargs -0 rm -f

If the load is of a problem use nice(1). Though I thought sendmail
brings a way on its own to delete messages from the queue, which
I would then prefer to use.

> Another option I've never tried passing two commands to find
> at the same time, but assuming doing that is not possible you
> could create a script that calls rm -f and sleeps a second in
> between each file deletion -

You can't give 2 commands to find's -exec and

> [natea at us-cfe002:/tmp]$ cat test.sh
> #!/bin/bash
> rm -fv $1
> echo "Sleeping 1 second"
> sleep 1

I strongly recommend mounting /tmp as nosuid,nodev *and* noexec,
especially on a server.

HTH,
Frank.



More information about the CentOS mailing list