Robert Menschel wrote:

DG> #!/bin/sh

DG> cd /home
DG> for i in */Maildir/.Spam ; do
DG>  find $i/{new,cur} -type f -mtime +7
DG> done | xargs -l -i rm -f

DG> The find part seems to ID all the older messages, but xargs doesn't seem to
DG> be removing them.  Any ideas?  Or a better approach?

I would replace your four lines with one:


find /home/Maildir/.Spam/{new,cur} -type f -mtime +7 -print -exec rm {} \;


Problem is... I think the original script did it for all users in /home. I think your 1-liner is going to look in a place that doesn't exist.

Personaly, I'd try something like:

 find /home -name "*/Maildir/.Spam/{new,cur}/*" -type f -mtime +7 -print -exec 
rm {} \;

or something like that.

John Hall suggested that, instead of "-exec rm", xargs should be used. I should 
point out that it *is* possible for the list of found files to be so long that it exceeds 
the allowed command-line length (don't laugh... I've actually *done* it). You probably 
don't have to worry until you get into the tens of thousands of messages (maybe fewer, 
since the filenames in Maildir are so damn long... and also because 'find' is going to be 
passing full pathnames), but that *is* a possibility if you're going to be doing all 
users on the system in one go.

Personally, I'd stick with the "-exec rm" unless it does bad things to your 
system load. Even though it's going to be slower, it's marginally less likely that you'll 
ever have to come back later to fix it if you, one day, get a shitload of spams to delete.

- Joe






Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to