procmail
[Top] [All Lists]

Re: Mail backup

1997-08-13 19:05:00
Brock Rozen asked,

| Why not just formail +1000 < file > newfile -- or would that just trash
| the first 1000 messages?

formail +1000s < file > newfile   would keep the first 1000 messages out of
newfile.  (Without the s or " -s", "formail +1000" would make no sense.)

Obviously formail -1000s < file > newfile is much easier than counting the
number in the file now and then, if it exceeds 1000, subtracting 1000 and
running formail +${difference}s to keep the last thousand messages.  But
that means backing up new messages at the beginning of the folder instead
of simply appending them.

So every time a new message arrives, you'd have something like this:

   :0c:backup.lock
   | cat - backup > /tmp/backup.$$ && mv /tmp/backup.$$ backup

which is a shell, a cat, and a mv every time a message arrives.  I think that
the few extra forks to figure out the excess over 1000 in the backup file
once per day in your cron job are less CPU work than inserting every message
at the beginning of the backup file.

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