procmail
[Top] [All Lists]

RE: splitting up huge mailbox (was mail assistance please)

2001-12-26 23:59:21

David W. Tamkin wrote:

In fact, procmail can do the allotment instead of sh, expr,
printf, and cat.

 FILENO=0 MSGMAX=500 formail -des procmail -p .allotrc < mailbox

I first tried writing the mailbox split routine in a procmail
script (although the effort was nothing compared to Dave's display of
mastery)
and was surprised to find that the environment variables
(FILENO, MSGMAX) weren't accessible from the script. A closer reading of
the manpage, of course would've helped, and as David shows in his example
above, the "-p" switch does the job:

       -p   Preserve  any  old  environment.   Normally  procmail
            clears the environment upon startup, except  for  the
            value  of TZ.  However, in any case: any default val<AD>
            ues will override any preexisting  environment  vari<AD>
            ables,  i.e.  procmail  will not pay any attention to
            any predefined environment variables, it will happily
            overwrite  them  with its own defaults.  For the list
            of environment variables that  procmail  will  preset
            see  the  procmailrc(5)  man page.  If both -p and -m
            are specified, the list of preset  environment  vari<AD>
            ables  shrinks to just: LOGNAME, HOME, SHELL, ORGMAIL
            and MAILDIR.

[...]
The special case where MSGMAX=1 -- that is, you want one message
per file --
can be done with no rcfile at all:

FILENO=0000 formail -des procmail -p DEFAULT='mbox.$FILENO'
/dev/null < mailbox

or start with FILENO=0001 if you prefer.  Note the strong quotes around
'mbox.$FILENO'.

Nice. Alternatively:

  formail -ds procmail DEFAULT=`pwd`/. /dev/null < mailbox

which will create message files numbered 1..N (no leading zeroes),
one file for each message. DEFAULT can be set to the full pathname of any
desired directory (with the addition of the the "/." suffix).

Since operations on the mail directory are implicitly locked,
we can safely use formail's -n switch to achieve additional throughput.
Assuming that we have 4 available processors, we might try:

  formail -n 4 -ds procmail DEFAULT=`pwd`/. /dev/null < mailbox

(The -e switch was dropped, above, per David's suggestion that it is
generally
not needed, and that it is not very efficient.)


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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