[Mimedefang] MD-Quarantine dir cleanup script?

Cormack, Ken kcormack at acs.roadway.com
Fri Sep 19 16:20:01 EDT 2003


The problems I've seen with both the xargs and "-exec rm" methods, though,
is that they can die if the resulting list of "hits" is too long.  That's
why I ultimately went with the while-loop.  It aint pretty, but it always
works, regardless of how many dirs are returned by the find.

Ken

-----Original Message-----
From: Kees Cook [mailto:kees at osdl.org]
Sent: Friday, September 19, 2003 3:45 PM
To: mimedefang at lists.roaringpenguin.com
Subject: Re: [Mimedefang] MD-Quarantine dir cleanup script?


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
_______________________________________________
MIMEDefang mailing list
MIMEDefang at lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang



More information about the MIMEDefang mailing list