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-0006.html>