Lock files in scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I was about to ask here how to do proper locking in a bash script when I 
found a page that addressed my objections to the race conditions I was 
finding in most sample code:

<http://www.davidpashley.com/articles/writing-robust-shell-scripts.html>

I just wanted to pass on the link to anyone else that needs this.

One thing not addressed is how to deal with an orphaned lock file (eg. if 
the system crashes with the lock held). He stores the PID in the lock file, 
so one could look up the matching process and see if it's the script that's 
expected to create it. Otherwise one should be safe in deleting the lock 
file and trying again.
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux