procmail
[Top] [All Lists]

Re: Slow updates to .procmailrc

1999-07-19 16:01:56
On Mon, 19 Jul 1999, Russell D. Weiss wrote:

I'm going to have a PERL script periodically updating my .procmailrc
file.  It's going to basically output text formed from info in a
relational database.  The problem is that the .procmailrc file will
be fairly large, and the script may take up to a minute or two to
output the .procmailrc file.  I was going to have it delete the file
and then rewrite it.  It would keep appending new recipes to it... 
I'm worried about mail coming in as the file is being updated.  Is
there a way I can use a lock file or use some other method to do the
update safely?  Or could I just have the PERL script output to a
.procmailrc.temp file and then use shell commands, like mv -f
.procmailrc.temp .procmailrc to rewrite the original file after the
script is run?  What's the best approach here? 

The standard approach is to write the file somewhere else (say,
.procmailrc-new) and then move it to the final name. Since moving on
the same filesystem ends up being just a name change, it's very fast.

So:

        generate-procmailrc > ~/.procmailrc-new
        mv ~/.procmailrc-new ~/.procmailrc

--
 John Hardin KA7OHZ                               
jhardin(_at_)wolfenet(_dot_)com
 pgpk -a finger://gonzo.wolfenet.com/jhardin    PGP key ID: 0x41EA94F5
 PGP key fingerprint: A3 0C 5B C2 EF 0D 2C E5  E9 BF C8 33 A7 A9 CE 76 
-----------------------------------------------------------------------
  Efficiency can magnify good, but it magnifies evil just as well.
  So, we should not be surprised to find that modern electronic
  communication magnifies stupidity as *efficiently* as it magnifies
  intelligence.  
                                  -- Robert A. Matern
-----------------------------------------------------------------------
   52 days until 9/9/99

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