How to do locking in shell scriptsTo do simple locking in shell scripts, you need an atomic system call
that fails if the target already exists, and that is directly exposed
in a utility program. Ignoring for a moment what System V did to
General locking with mkdir LOCK 2>/dev/null || exit 0 echo running locked rmdir LOCK Locking with echo $$ >$$ if ln $$ LOCK 2>/dev/null; then echo running locked rm $$ LOCK else rm $$ fi In both cases you really want a private directory for the locks. If you
have to use a shared directory like |
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |