Jesper Pedersen asked,
| I have a problem with my procmail setup, which only occurs sometimes, ie
| lots of times it works fine.
|
| Well here's the recipe I have problem with:
| :0c:lock
| |echo $VAR8 lines, `/usr/local/gnu/bin/date +%e`/`/usr/local/gnu/bin/date
+%m`/`/usr/local/gnu/bin/date +%y`, `/usr/local/gnu/bin/date
+%k`:`/usr/local/gnu/bin/date +%M`, $VAR9, $VAR10 | gzip >> log.gz
Oy! You know that you can reduce all those date calls to one:
/usr/local/gnu/bin/date +'%e/%m/%y, %k:%M'
| It works fine most of the time, but once in a while I get the following
| message:
|
| ======================================================================
| procmail: Error while writing to "echo $VAR8 lines, `/usr/local/gnu/bin/date
+%e`/`/usr/local/gnu/bin/date +%m`/`/usr/local/gnu/bin/date +%y`,
`/usr/local/gnu/bin/date +%k`:`/usr/local/gnu/bin/date +%M`, $VAR9, $VAR10 |
gzip >> log.gz"
| ======================================================================
The problem, though, is that you are executing an action that doesn't read
stdin, and procmail expects all actions to operate on the message text, so
when it can't feed the message to the command, it thinks something may be
wrong.
The solution is the `i' flag, which tells procmail to overlook errors on
trying to write the message text into the pipe (backslash-newline added for
my own presentation, not to criticize Jesper for the long line):
:0ci:lock
|echo $VAR8 lines, `/usr/local/gnu/bin/date +'%e/%m/%y, %k:%M'`, $VAR9, \
$VAR10 | gzip >> log.gz
Longer messages are more likely to run into this problem than shorter ones.
Since, in fact, procmail shouldn't even waste effort writing the text to
the command, you can reduce the load by telling it to write only the head
(or only the body if typically this recipe gets called for mail with short
bodies):
:0hci:lock
|echo $VAR8 lines, `/usr/local/gnu/bin/date +'%e/%m/%y, %k:%M'`, $VAR9, \
$VAR10 | gzip >> log.gz
Another thing I don't understand -- maybe the rest of your code explains the
logic -- is why you are naming a lockfile when one (log.gz.lock) is implicit.