SUMMARY: Scripted access to sentral repository

From: Johan Hartzenberg (jhartzen_at_csc.com)
Date: 05/30/03

  • Next message: Moughan, Laurence: "LOM"
    To: sunmanagers@sunmanagers.org
    Date: Fri, 30 May 2003 11:33:13 +0200
    
    

    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


  • Next message: Moughan, Laurence: "LOM"