Hugh McIntyre wrote: > Kyle McDonald wrote: >> Any advice on a good way to acquire a lock in a shell script? > > 1. Install procmail. > > 2. Use the following: > > if lockfile $FILE ; then > # do stuff with the file locked.... > rm -f $FILE > fi
Hmm. An important correction is, generally, to use: lockfile ${FILE}.lock # do stuff rm -f ${FILE}.lock ^^^^^ I.e. don't remove the original file, of course... Hugh.