procmail
[Top] [All Lists]

Re: Controlling the procmail logfile ?

1997-08-22 13:11:51
W. Wesley Groleau wrote, describing his system of having a separate logfile
for every incoming message,

| If there was a
| duplicate [in naming the logfile], I believe one procmail would wait until
| the other was finished and then use the same file.

No, there would be no waiting.  Procmail does not lock the logfile.  If two
procmail processes want to use the same logfile, they'll happily write to
it together, clashing away to their electronic hearts' content.  As Wesley
said, though, in the setup he was describing the situation would be highly
unlikely.

I use only one logfile per account for all incoming mail, and interleaved
log entries are very common.  If that were a problem for me, I'd use global
lockfiles.

[I almost suggested that, since Wesley's suggestion to Vikas has one logfile
 per message, one could use the logfile itself as the global lockfile and
 thus make any other procmail process that wanted to use the same logfile
 wait for it, but (1) one would need to create it as the lockfile first,
 because if one created it as the logfile first, the process couldn't get the
 lock; (2) since it was created as the lockfile, one would need to chmod it
 from 400 to 600 to use it as a logfile; (3) because other procmail processes
 using different logfiles {and thus different global lockfiles} might try to
 save to the same folders, one would still need local lockfiles on individual
 recipes, and if one shares the code it would look very strange; but here's
 the real killer (4): upon exit, procmail would rm the lockfile, and if it's
 also the logfile, there goes your log information.  Instead,]

Here's an idea: include $HOST as well as $$ in the name of the logfile.  Then
you can't possibly get a conflict.

This time the list will be spared my usual suggestion to extract timestamp
info from the From_ line to avoid running date, because if one wants to
reprocess mail already received without changing the incoming timestamp,
one would want to start a fresh logfile, not to append to the logfile from
the original arrival of that message.

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