Hi all, I found an article (with python script) on how to clean up Maildir folder for old email messages from http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/ . As I understand, this will be run by each user after login. How can I make this runs at least once a month and delete all users message with age more than one month for example using crontab? I am using Postfix, MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV and CentOS4.4 as mail server. If you need further input, please just let me know. Thanks in advance for help. Thanks. junji linux registered user #253162 Send instant messages to your online friends http://uk.messenger.yahoo.com
Jun Salen wrote:> Hi all, > > I found an article (with python script) on how to > clean up Maildir folder > for old email messages from > http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/ > . As I understand, this will be run by each user > after login. How can I make this runs at least once a > month and > delete all users message with age more than one month > for example using crontab? I am using Postfix, > MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV > and CentOS4.4 as mail server. If you need further > input, please just let me know. Thanks in advance for > help. Thanks. >Is your maildir info stored in mysql or in berkeley dbs? You want write a script that will run under the uid/gid of the owner of the maildir base directory. It should feed each Maildir to the python script with appropriate parameters (I have not looked at it) so the thing to figure out is how to get the list of Maildirs.
Well as you want to delete you don't need to worry about ownership of the Maildir. Create a script that starts the script for each Maildir you have on your system. Run the script from a crontab or from the cron.monthly directory. You need a list of the Maildir directories. Depending on your setup you can create it on the fly or keep track of the Maildir places ina file and read the file for usage with the script. If you need more help just send an email, private is fine. Peter On Wed, 2007-01-31 at 01:08 +0000, Jun Salen wrote:> Hi all, > > I found an article (with python script) on how to > clean up Maildir folder > for old email messages from > http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/ > . As I understand, this will be run by each user > after login. How can I make this runs at least once a > month and > delete all users message with age more than one month > for example using crontab? I am using Postfix, > MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV > and CentOS4.4 as mail server. If you need further > input, please just let me know. Thanks in advance for > help. Thanks. > > junji > linux registered user #253162 > > Send instant messages to your online friends http://uk.messenger.yahoo.com > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos > >
Jun Salen wrote:> Hi all, > > I found an article (with python script) on how to > clean up Maildir folder > for old email messages from > http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/ > . As I understand, this will be run by each user > after login. How can I make this runs at least once a > month and > delete all users message with age more than one month > for example using crontab? I am using Postfix, > MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV > and CentOS4.4 as mail server. If you need further > input, please just let me know. Thanks in advance for > help. Thanks. >to run the script monthly, put it in /etc/cron.monthly. but you can also run it daily or weekly (but only delete files with age > 1 month). Instead of deleting, consider moving the files to some place to give you time to recover should something bad happens... <untested> maildir_list=.... for _maildir in $maildir_list; do for d in `find $maildir -type d -name cur`; do find $d -type f -ctime +30 -exec rm {} \` done done </untested> </untested>
Jun Salen wrote:> Hi all, > > I found an article (with python script) on how to > clean up Maildir folder > for old email messages from > http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/ > . As I understand, this will be run by each user > after login. How can I make this runs at least once a > month and > delete all users message with age more than one month > for example using crontab? I am using Postfix, > MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV > and CentOS4.4 as mail server. If you need further > input, please just let me know. Thanks in advance for > help. Thanks. > > junji > linux registered user #253162 > > Send instant messages to your online friends http://uk.messenger.yahoo.com > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >Why not just use the IMAP_EMPTYTRASH option in imapd? From the imapd config file:> ##NAME: IMAP_EMPTYTRASH:0 > # > # The following setting is optional, and causes messages from the given > # folder to be automatically deleted after the given number of days. > # IMAP_EMPTYTRASH is a comma-separated list of folder:days. The default > # setting, below, purges 7 day old messages from the Trash folder. > # Another useful setting would be: > # > # IMAP_EMPTYTRASH=Trash:7,Sent:30 > # > # This would also delete messages from the Sent folder (presumably copies > # of sent mail) after 30 days. This is a global setting that is > applied to > # every mail account, and is probably useful in a controlled, corporate > # environment. > # > # Important: the purging is controlled by CTIME, not MTIME (the file time > # as shown by ls). It is perfectly ordinary to see stuff in Trash that's > # a year old. That's the file modification time, MTIME, that's displayed. > # This is generally when the message was originally delivered to this > # mailbox. Purging is controlled by a different timestamp, CTIME, > which is > # changed when the file is moved to the Trash folder (and at other > times too). > # > # You might want to disable this setting in certain situations - it > results > # in a stat() of every file in each folder, at login and logout. > # > > IMAP_EMPTYTRASH=Trash:7,Sent:30I dont use courier any more but back when I did I used it to delete mailing list messages more than 6 months old hope this helps Dunc
Hi Dunc, That is perfect, I will try that. Thanks. Date: Sat, 03 Feb 2007 12:17:00 +0000 From: Dunc <centos at duncb.co.uk> Subject: Re: [CentOS] Maildir Cleanup To: CentOS mailing list <centos at centos.org> Message-ID: <45C47D3C.4020300 at duncb.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Jun Salen wrote:> Hi all, > > I found an article (with python script) on how to > clean up Maildir folder > for old email messages from >http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-mails/> . As I understand, this will be run by each user > after login. How can I make this runs at least oncea> month and > delete all users message with age more than onemonth> for example using crontab? I am using Postfix, > MailScanner, SpamAssassin, Courier IMAP/POP3, ClamAV > and CentOS4.4 as mail server. If you need further > input, please just let me know. Thanks in advancefor> help. Thanks. > > junji > linux registered user #253162 > > Send instant messages to your online friendshttp://uk.messenger.yahoo.com> _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >Why not just use the IMAP_EMPTYTRASH option in imapd?>From the imapdconfig file:> ##NAME: IMAP_EMPTYTRASH:0 > # > # The following setting is optional, and causesmessages from the given> # folder to be automatically deleted after the givennumber of days.> # IMAP_EMPTYTRASH is a comma-separated list offolder:days. The default> # setting, below, purges 7 day old messages from theTrash folder.> # Another useful setting would be: > # > # IMAP_EMPTYTRASH=Trash:7,Sent:30 > # > # This would also delete messages from the Sentfolder (presumably copies> # of sent mail) after 30 days. This is a globalsetting that is> applied to > # every mail account, and is probably useful in acontrolled, corporate> # environment. > # > # Important: the purging is controlled by CTIME, notMTIME (the file time> # as shown by ls). It is perfectly ordinary to seestuff in Trash that's> # a year old. That's the file modification time,MTIME, that's displayed.> # This is generally when the message was originallydelivered to this> # mailbox. Purging is controlled by a differenttimestamp, CTIME,> which is > # changed when the file is moved to the Trash folder(and at other> times too). > # > # You might want to disable this setting in certainsituations - it> results > # in a stat() of every file in each folder, at loginand logout.> # > > IMAP_EMPTYTRASH=Trash:7,Sent:30I dont use courier any more but back when I did I used it to delete mailing list messages more than 6 months old hope this helps Dunc junji linux registered user #253162 Send instant messages to your online friends http://uk.messenger.yahoo.com