Search code examples
perlemailsendmailprocmail

Process mail bursts one at a time


we receive bursts of mails from our IDS that we are postprocessing to create incident reports, forward them to request tracker, etc. Right now, we have one script that does all the postprocessing that is called by procmail according to rules in /etc/aliases. Something like:

ids-report: "|/opt/ids/process.pl"

Now, the problem is that running many instances of this script because of mail bursts can lead to memory depletion and some synchronization nastyness.

In my script, I tried using Sys::RunAlone, but found it suboptimal.

I would like procmail to feed my script one mail from queue at a time, but I have not found a way to do it.

Do you guys have any idea, what could I do? Out-of-the-box solutions are welcomed too...

Thanks.


Solution

  • I second Georgi Rangelov's answer but if you are seriously asking how to run only one message at a time in Procmail, the answer is to use a lock file.

    :0:only1.lock
    | /opt/ids/process.pl
    

    This means, if the file only1.lock exists, wait. Once it's gone, create it, run the pipe, and then remove the lock file when done.

    See also http://porkmail.org/era/procmail/mini-faq.html#locking