procmail
[Top] [All Lists]

Re: Detecting failed execution via pipe & re-executing later

2003-07-23 14:37:02
Aaron Turner wrote,

So I have this need to run mail matching a certain critera through an
executable which queries/updates a database.  The problem is that the
database is backed up on a regular basis, and to get a good backup, we
have to take it down.

Hence, I want to detect the script failing, and re-queue up the mail for
delivery in say 5 minutes.  Any suggestions on how to complete this
script?

:0 W
* ^Subject.*ticketing system
* ^FROM(_dot_)*(_at_)skytel\(_dot_)com
| /export/home/secpage/bin/skytel-close.pl

:0 e
<do something to re-queue the email for future delivery>

OK, you want to try a program every five minutes until it returns a non-zero exit code ...

In .procmailrc or whatever the principal rcfile is called,

 :0
 * ^Subject.*ticketing system
 * ^FROM(_dot_)*(_at_)skytel\(_dot_)com
 { INCLUDERC=skytel-close.rc }

and in skytel-close.rc,

 :0w
 | /export/home/secpage/bin/skytel-close.pl

 :0a
 { SWITCHRC }

 ticktock=`sleep 300`
 SWITCHRC = $_

But given the reason for these failures, I think that this is a better approach: wrap the backup program in a script (or modify the wrapper script it already has if it has one) to use lockfile:

 lockfile whateveritsname.lock
 backup_the_database
 rm -f whateveritsname.lock

and change the colon line of your current procmail recipe to

 :0W:/path/to/whateveritsname.lock

One other thing that concerns me is the way you have "FROM" in all caps. Usually that means that the coder thinks FROM is some special token in procmail, like ^TO or ^TO_ or ^FROM_DAEMON or ^FROM_MAILER. It isn't, and I hope you didn't think it was.


_______________________________________________
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>