FAQ
Using "touch" and "test -e" as a lock test is not safe. If the shell
dies for any reason, the lock file will get stale.

If you sync station is linux, a safer option is to use the flock(1) program:


*NAME
flock - Manage locks from shell scripts

SYNOPSIS
flock [-sxon] [-w timeout] lockfile [-c] command...

flock [-sxon] [-w timeout] lockdir [-c] command...

flock [-sxun] [-w timeout] fd
*

Here is the lock part of my mirror script:

*RunLocked()
{
....
}

**(
flock -w 1 200
if [ "$?" -ne 0 ] ; then
echo "Error, lock is already taken..."
exit
else
RunLocked
fi
) 200> ${lockdir}/mirror.centos.lock

*

Jonny

--
Jo?o Carlos Mendes Lu?s - Computer& Networking Engineer
jonny at jonny.eng.br

On 07/12/2011 11:56 AM, Adam wrote:
admin wrote:
Yes It would be great . I'm still rsync centos repo.
Could you provide me bash script to rsync with file locking ?
Attached is a bash locking rsync script. This script is pretty
informative and intelligent. It verifies that the time stamp of the
server you are syncing form is newer then yours before it syncs.
Hence it shouldn't ever delete files you have already downloaded if
you hit an old mirror.

Adam


_______________________________________________
CentOS-mirror mailing list
CentOS-mirror at centos.org
http://lists.centos.org/mailman/listinfo/centos-mirror
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.centos.org/pipermail/centos-mirror/attachments/20110712/502354f5/attachment.html

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 37 | next ›
Discussion Overview
groupcentos-mirror @
categoriescentos
postedJul 11, '11 at 5:58p
activeJul 18, '11 at 5:00a
posts37
users10
websitecentos.org
irc#centos

People

Translate

site design / logo © 2022 Grokbase