On Sat, December 31, 2005 11:29 am, Sam Varshavchik said:
> Chris Purves writes:
>
>> On Sat, December 31, 2005 10:27 am, Sam Varshavchik said:
>>> Chris Purves writes:
>>>> On Fri, December 30, 2005 7:51 pm, Sam Varshavchik said:
>>>>> Chris Purves writes:
>>>>>> [EMAIL PROTECTED] wrote:
>>>>>>>
>>>>>>>>I would like to know if it is possible to have courier remove old
>>>>>>>>messages, say 6 months old, from trash or mailing list folders.
>>>>>>>>
>>>>>>>>I am using courier-imap with maildirs.
>>>>>>>
>>>>>>> imapd file....
>>>>>>>
>>>>>> That has the capability that I want, but is it possible to have a
>>>>>> seperate file for each user?
>>>>>
>>>>> No.
>>>>>
>>>> What would be the best way to do what I want?  Write a script that
>>>> deletes
>>>> old files and add that to my crontab?
>>>
>>> That'll work.  Be sure to watch out for common pitfalls.
>>>
>>> find ~user/cur -mtime +30 --exec rm {} \;
>>>
>>> The user doesn't log in, or get any mail for 30 days.  You get paged at
>>> 2am
>>> by an alarm for a failed cron job, because rm tried to remove the cur
>>> directory itself.
>>>
>> Thanks for your help.  I made a bash script using your suggestion that
>> removes old mail from specified directories:
>>
>> #!/bin/bash
>>
>> # this script purges mail older than specified days from specified
>> directories
>>
>> # enter directory names to be purged, seperated by spaces
>> DIRS="trash sent-mail lists.clamav-announce"
>>
>> # enter number of days to purge if older
>> DAYS="180"
>>
>> for DIR in $DIRS
>> do
>>   find ~/Maildir/.$DIR/cur -mtime +$DAYS -exec rm {} \;
>> done
>
> Like I said, there'll be a small chance that you'll get paged at 2am in
> the
> morning, six months from now, or so, to clean up after a failed job.
>

I experimented on an empty directory and indeed, as you said, find wanted
to remove the directory, but by adding -type f as Michael suggested, there
was no problem with the empty directory.

-- 
Good day, eh.
Chris



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Courier-imap mailing list
Courier-imap@lists.sourceforge.net
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap

Reply via email to