Avoiding Multiprocess Errors in Bash Shell
johndcook.com
johndcook.com
---
This technique [36.27: Shell Lockfile, sent in from Greg Ubben] doesn't work for scripts run as the superuser (root). It depends on the fact that a standard user can't write a file without write permission. But root can write any file, whether it has write permission or not. If there's a chance that root might run your script, you might want to add a test of the UID--by running the id command, for instance--and be sure that the UID isn't 0 (the superuser's).