From: Johan Hartzenberg (jhartzen@csc.com)
Date: Fri May 30 2003 - 05:33:13 EDT
Hi all, Thanx for the quick reponses. The prise for the best answer goes
to Ole-Morten Duesund, who said:
Something like :
if mkdir $REPOSITORY/.lockdir; then
MergeRepository
rmdir $REPOSITORY/.lockdir
fi
Should work, mkdir returns false if the directory already exists. Btw,
you might want to do :
if mkdir $REPOSITORY/.lockdir 2> /dev/null; then
to avoid the error message from mkdir if/when it fails.
On Fri, 2003-05-30 at 10:14, Johan Hartzenberg wrote:
> Has anybody implemented file locking via shell scripts?
>
> I need an effective way to allow multiple hosts to collect some data
> locally and then dump it into a structured repository shared via NFS,
which
> means I will nead some form of file locking.
>
> I would like to avoid race conditions from statements like the following:
>
> [ ! -f $REPOSITORY/.lockfile ] && touch $REPOSITORY/.lockfile &&
> MergeRepository && rm $REPOSITORY/.lockfile
>
> Any ideas?
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:26:29 EDT