--On Wednesday, July 13, 2011 12:35 PM -0600 Devin Reade gdr@gno.org wrote:
However, although I like the trap mechanism for dealing with cleaning up temporary files (especially those files or directories containing temporary files created by mktemp(1)), I don't think that it's the right tool for lock files. Instead, have a look at flock(1) to avoid the race conditions. (See flock(2) about its unsuitability for locks on NFS filesystems, though.)
Thanks, that looks much better.
http://linux.die.net/man/1/flock
I'm running my script as a normal user so the lock will be in the user's home directory.