procmail
[Top] [All Lists]

Re: Slow updates to .procmailrc

1999-07-19 18:12:51
"Russell D. Weiss" <rweiss(_at_)inforelay(_dot_)com> writes:
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 latter.  No need to call out to the shell to move it into place --
just use the rename() function.  It should end up looking something
like this:

open(RCFILE, ">.procmailrc.new")
                                or die "$0: can't open .procmailrc.new: $!";

....blah blah blah...

close(RCFILE)                   or die "$0: can't close and flush: $!";
rename(".procmailrc.new", ".procmailrc")
                                or dir "$0: can't rename rcfile: $!";


Philip Guenther

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