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

nate centos at linuxpowered.net
Mon Aug 31 21:57:09 UTC 2009


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 {} \;

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 -

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


[natea at us-cfe002:/tmp]$ find blah3/ -type f -exec /tmp/test.sh {} \;
removed `blah3/pd4-ads01-splunk-diag-20090827_193250.tgz'
Sleeping 1 second
removed `blah3/pd3-ads01-splunk-diag-20090827_183136.tgz'
Sleeping 1 second
removed `blah3/pd4-ads01-splunk-listtails.log'
Sleeping 1 second
removed `blah3/pd3-bgas01-splunk-listtails.log'
Sleeping 1 second
removed `blah3/pd3-ads01-splunk-listtails.log'
Sleeping 1 second
removed `blah3/splunk-diags-multiserver-20090827_1700.tar'
Sleeping 1 second
removed `blah3/pd4-bgas01-splunk-listtails.log'
Sleeping 1 second
removed `blah3/pd3-bgas01-splunk-diag-20090827_183148.tgz'
Sleeping 1 second
removed `blah3/pd4-bgas01-splunk-diag-20090827_193229.tgz'
Sleeping 1 second


adjust sleep level as desired..

nate





More information about the CentOS mailing list