procmail
[Top] [All Lists]

Re: help with 'lockfile' in shell script

1997-12-07 02:39:01
At 01:47 AM, 07 December 1997, Timothy J Luoma 
<luomat+procmail(_at_)luomat(_dot_)peak(_dot_)org> wrote:
How can I setup procmail and this shell script to make sure that it waits  
for 'compactmail' to finish before delivering new mail?

I thought about this:

#!/bin/sh

LOCKFILE=${HOME}/.procmail/global-procmail.lock

while [ -r $LOCKFILE ]; do
      sleep 5
done

touch $LOCKFILE
/usr/local/bin/compactmail -u -d 3 Backups
/bin/rm -f $LOCKFILE

exit 0

But what happens if mail comes in right between the 'done' and the 'touch'  
lines?  I realize it's a longshot....

Basically: is there a better way?

Check out the lockfile program that comes with procmail.  It should be
exactly what you need.

-- 
Aaron Schrab     aaron(_at_)schrab(_dot_)com      http://www.execpc.com/~aarons/
 Let's say the docs present a simplified view of reality...    :-)
    --Larry Wall

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