procmail
[Top] [All Lists]

Re: Run scr after all mail retrieved

1999-06-06 05:42:25
On 01 Jun 1999 22:12:09 -0700, Harry Putnam <reader(_at_)newsguy(_dot_)com>
wrote:
But keeping about 700 messages. I've edited the recipes so they
work for me like so:
:0 c
 backup/.
 :0 ic
 | cd backup && rm -f dummy `ls -t [0-9]* | sed -e 1,700d`
This is very slow ...  it runs on each message.

Generally, a better approach might be to keep, say, a day's (or two
days', or a week's) worth of messages in one particular backup
directory, and rename that regularly from within a cron job.

In order to avoid having to lock the directory (so as to avoid
accidents if you have an incoming message being delivered while you
are only half done with switching in a new day's directory in place of
the old), you might want to make sure "backup" is always a symlink,
and make the cron job something like

#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin     # or whatever suits your needs
dirname=`date +backup-%Y%m%d` 
mkdir $dirname && ln -fs $dirname backup
# ... warn if the above didn't succeed
# ... stuff to remove files / directories you no longer want to keep

I'd run this daily and keep, say, the seven latest backup dirs and zap
the rest. You can fish out the individual files as you need them and
it's fairly easy to get at them all with normal shell wildcards if you
need that. (You might want all of this to live in its own directory
underneath Mail or /tmp or where-ever.)

So from Procmail, you only need to store a copy of each message in the
backup directory (which would be a symlink to a directory whose name
contains today's date), and you can let the cron job (or something
that runs at the end of your fetchmail session, in your particular
case, if you can figure out how to hook in something there) take care
of the rest of the housekeeping.

Hope this helps,

/* era */

-- 
.obBotBait: It shouldn't even matter whether     <http://www.iki.fi/era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>
 * Sign the European spam petition! <http://www.politik-digital.de/spam/en/> *

<Prev in Thread] Current Thread [Next in Thread>