SUMMARY: Scripted access to sentral repository

From: Johan Hartzenberg <jhartzen_at_csc.com>
Date: Fri May 30 2003 - 05:36:46 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
Received on Fri May 30 05:36:37 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:11 EST