SCIENTIFIC-LINUX-USERS Archives

November 2013

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nico Kadel-Garcia <[log in to unmask]>
Reply To:
Nico Kadel-Garcia <[log in to unmask]>
Date:
Sun, 24 Nov 2013 20:07:53 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
There are so many technologies, in so many scripts, it's hard to
choose. I'd look at "rsnapshot" which has a decent management of lock
files for rsync based mirrors.

On Sun, Nov 24, 2013 at 6:54 PM, Rainer Laatsch <[log in to unmask]> wrote:
>
> On Sat, 23 Nov 2013, Nico Kadel-Garcia wrote:
>>
>> And a lockfile to prevent multiple copies of your script from piling
>> up, especially if you've got this on a cron job
>
> What is a good method to create a lockfile? The often used primitive
>   [ -e lockfile ] && return 1; touch lockfile
> does not work 100% , as possibly seen by multiply running this script:
>
> --- snip ---
> :
> rm lockfile    2>/dev/null
> rm lock.result 2>/dev/null
>
> i=0
> while [ $i -lt 99 ] ; do
>
> (
> if [ ! -e lockfile ] ; then
> touch lockfile
> echo "Owner $i" >> lock.result          ## believe we are the lock owner
> else
> echo "Cant lock, $i"  >> lock.result    ## lockfile is already existing.
> fi
> ) &
>
> let i=$i+1
> done
>
> grep Owner lock.result
> count=`grep Owner lock.result | wc -l`  ## how many processes think they own the lock?
>  [ $count -gt 1 ] && echo "BAD lock method [$count] owners"
>
> --- snip ---
>
> Regards, R.

ATOM RSS1 RSS2