[Mimedefang] MD-Quarantine dir cleanup script?

Kees Cook kees at osdl.org
Fri Sep 19 15:45:01 EDT 2003


On Fri, Sep 19, 2003 at 03:17:32PM -0400, Cormack, Ken wrote:
> I dont recall seeing David's one-liner, per-se, but here's what I use:
> 
> 	cd /var/spool/MD-Quarantine
> 	find . -type d -ctime +4 -print | while read OLD
> 	do
> 	  rm -r ${OLD} 2> /dev/null
> 	done
> 
> I suppose this could be re-written to:
> 
> 	find . -type d -ctime +4 -exec rm -r {} \;
> 
> Et viola!  One-liner.

doing an exec per match can be pretty CPU-intensive (lots of execs).  You
can also use xargs:

find /var/spool/MD-Quarantine -type d -ctime +7 | xargs rm -rf

(and adding "-maxdepth 1" if your "find" supports it will make it even 
faster)

I'm actually using "tmpwatch" on RedHat:

# This cleans up the old quarantine directories (more than a week old)
0 7 * * * root /usr/sbin/tmpwatch -cf 168 /var/spool/MD-Quarantine


-- 
Kees Cook
Open Source Development Lab
kees at osdl.org



More information about the MIMEDefang mailing list