On Sat, Mar 18, 2006 at 12:44:55AM -0500, Zenon Panoussis wrote:
if [ -f /some/path/lockfile ] then exit
The downside of lockfiles is that if your script crashes they stay behind and keep blocking until you realise it and remove them manually. A somewhat better way to do this could be to
Not necessarily. Do something like this:
trap "rmdir ${LOCKFILE}" EXIT TERM INT QUIT
and it'll get removed no matter the reason your script quit.
It's better to use directories than regular files for lockfiles, because you can use mkdir to both test for existence and create the lock if it isn't there already.
It'd also be better to trap each exit individually and log a separate message for each....