[H-GEN] Can procmail trigger a script?

Bruce Campbell bc at humbug.org.au
Sun Dec 11 05:10:28 EST 2005

On Sun, 11 Dec 2005, Harry Phillips wrote:

> Edwin Groothuis wrote:
>>> I have just subscribed to the clamav database update list and was 
>>> wondering if procmail (or something else) can be used to trigger a script 
>>> to download the latest database.
>> This will do the trick:
>> * ^List-Id: Ports bug reports .freebsd-ports-bugs.freebsd.org.$
>> {
>>     :0 c
>>     |lockf /tmp/scanmail.lock 
>> /home/edwin/ports/incoming-prs/bin/scanmail.pl
>>     :0
>>     .freebsd-pb/
>> }
> What part does what? Does the first part run the scanmail.pl script and the 
> second part put the message somewhere? If so, what is the lock file for?

The first part operates on a copy of the message, and runs the scanmail.pl 
(or whatever program you wish) script within an exclusive lock. 
Alternatively, you can also use the locking mechanism within procmail 
(better only in that its not a seperate process):

 	:0 c:
 	| /the/command/to/run

The second part saves the message in a known location, presumably for 
debugging purposes.

> As I said this e-mail address is used for nothing else but receiving notices 
> that the database has been updated, I don't need to keep the messages.

I'd suggest that you keep the messages for the first week or so, to ensure 
that you catch any bugs.  The important thing to remember is that you use 
a lockfile to ensure that only one process is updating the clamAV database 
at any time.

This ensures that your machine doesn't fall over in the common occurence 
of multiple program-triggering messages being received at the same time 
(for instance, if it or the remote has been offline for a few days, or if 
the program has not been written with simultanous invocation in mind).

Personally, I'm more of the opinion that the MTA's responsibility is to 
deliver the mail, and let cron-triggered/daemonised programs do serious 
cpu/disk-bound activity with the resulting mail files.  Allowing an 
outside agency control the load on your server is not a good thing, and 
has a nasty tendency to keep you up at nights.


More information about the General mailing list