[ILUG] find question

admin at revoltingdigits.com bryanhunt at newmailserver.coast-country.com
Tue Apr 13 20:33:57 IST 2004


echo /home/**/Maildir/.spam/{cur,new}

>will do just nicely. The above find command will list the name of very
>file of any type in all of the above directories, including those
>directories themselves.
>
>
>Niall
>--
>Irish Linux Users' Group
>http://www.linux.ie/mailman/listinfo/ilug/
>
>  
>
Hmm , actually I found I had to do it slightly differently

Here is the script that I was hacking away on, someone may find it 
usefull. It is run from cron.

I would welcome any feedback anyone wants to make about it.

--B



-------------- next part --------------
#!/bin/sh
echo DEFANGED.0
exit
#!/bin/bash

#spambackup.sh 

#This script backs up spam and ham used for sa-learn into the defined 
#directory, the purpose of this is to speed up daily learning times. As
#you may have guessed I am using an IMAP based server (courier)

#'GLOBALS DEFINITION

FROM_HAM="/var/imapshared/.SpamFalsePositive/cur/ /var/imapshared/.SpamFalsePositive/tmp/"
FROM_SPAM="/var/imapshared/.SpamEscaped/cur/ /var/imapshared/.SpamEscaped/tmp/"
TO_HAM_BACKUP=/var/spamassassin/spam.hist/ 
TO_SPAM_BACKUP=/var/spamassassin/ham.hist/ 

echo FROM_HAM=${FROM_HAM}
echo FROM_SPAM=${FROM_SPAM}
echo TO_HAM_BACKUP=${TO_HAM_BACKUP}
echo TO_SPAM_BACKUP=${TO_SPAM_BACKUP}

#The reason for this is that I am using thunderbird's spam capabilities 
#to automatically identify spam on the client side. For me personally 
#but not for the rest of the staff this means that I will also be dumping 
#previously identified spam into the SpamEscaped directory. 
#There is no point in sending messages to be identified twice so this is 
#basically just a bit of housekeeping. 

grep -ir "\[SPAM\]" ${FROM_SPAM}  |\
sed -e "s/\(.*\):Subject.*/\1/g" | xargs rm -f

#Do the spam/ham learning

ham_learn=`sa-learn --ham -C /etc/mail/spamassassin \
--dir /var/imapshared/.SpamFalsePositive/cur/`
echo "ham: " ${ham_learn}

spam_learn=`sa-learn --spam -C /etc/mail/spamassassin \
--dir /var/imapshared/.SpamEscaped/cur/`
echo "spam: " ${spam_learn}


#Move old messages into backup

find  ${FROM_HAM} -not -type d -mtime +1 \
-exec mv {} ${TO_HAM_BACKUP} \;

find  ${FROM_SPAM} -not -type d -mtime +1\
 -exec mv {} ${TO_SPAM_BACKUP} \;

#Clean up the users spam directory , dont forget to set this to 
#a reasonable time like 3 days or so , that's what mtime means

echo "cleaning up current spam"
find /home -path '**/Maildir/.spam/cur/*' -not -type d -mtime +3 \
 -exec rm {}  \;
echo "cleaning up tmp spam"
find /home -path '**/Maildir/.spam/tmp/*' -not -type d -mtime +3 \
 -exec rm {}  \;
echo "cleaning up new spam"
find /home -path '**/Maildir/.spam/new/*' -not -type d -mtime +3 \
 -exec rm {}  \;

echo "cleaning up current trash"
find /home -path '**/Maildir/.Trash/cur/*' -not -type d -mtime +3 \
 -exec rm {}  \;
echo "cleaning up tmp trash"
find /home -path '**/Maildir/.Trash/tmp/*' -not -type d -mtime +3 \
 -exec rm {}  \;
echo "cleaning up new trash"
find /home -path '**/Maildir/.Trash/new/*' -not -type d -mtime +3 \
 -exec rm {}  \;












More information about the ILUG mailing list