It’s just a mirror script and all but there is still a chance of having a race condition when using a pid/locking system like that. I used to do it the same way until recently I discovered a utility called flock. You can either use it within your script or you could simply use a one liner in your crontab. I’ve included examples both ways. flock is provided by util-linux package Here’s one way via CRON 0 */6 * * * /usr/bin/flock -x -w 0 200 -c '/usr/bin/rsync -azH --delete --delay-updates –stats --no-motd msync.centos.org::CentOS /mirror/centos' 200>/var/lock/centos_mirror_sync And here’s the way I do with with a script, my cron entry looks like the following... 0 */6 * * * /sbin/centos_mirror_sync >> /var/log/centos_mirror_sync.log 2>&1 The script is at http://mirrors.ndchost.com/ndchost/scripts/rsync_mirror_script The script names the lock file after whatever you name the script, so if you rename the script to centos_mirror_sync and have another copy named debian_mirror_sync they should not conflict with each other. -- Shaun Reitan Network Data Center Host, Inc. www.ndchost.com From: Ryan Becker Sent: Thursday, February 28, 2013 11:11 AM To: Mailing list for CentOS mirrors Subject: Re: [CentOS-mirror] setup mirror and lock files Sure thing, I'm not at the office right now but when I am I'll send it off to you. On Feb 28, 2013 1:02 PM, "Tony Schliesser" <tony at schliesser.org> wrote: Ryan - If you don't care to share your mirror script, I'd like to see it. Thanks, Tony Hi Jim, it's quite easy to do with a script. This first section here checks to see if a lock is present, and if it is, the script bails: if [ -f /var/lock/subsys/rsync_updates ]; then echo "Updates via rsync already running." echo "--ERROR: REPOSITORY SYNC ABORTED AT `date`--" exit 0 fi When I begin my sync, it touches the lock file (touch /var/lock/subsys/rsync_updates), and when finished, removes it (/bin/rm -f /var/lock/subsys/rsync_updates). If you need any help or wish to see my full script, just let me know and I can provide it. On Wed, Feb 27, 2013 at 8:42 PM, Jim Hartnett <mirrors at gawsolutions.us> wrote: Ok, I have the lock scripts setup and working, I think we're ready to add our mirror. (information repeated): mirror Url: http://mirrors.gawsolutions.us/centos bandwidth: 100 Mbps up/down unmetered transfer located in dallas, tx, usa Geeks at Work Solutions centos machine with apache rsync twice a day at offset minutes (reduces peak for even hour starts) - -Jim P.S: sorry if this message gets repeated multiple times. I just found out my email client was having some issues with the account I use for mirror mailing lists _______________________________________________ CentOS-mirror mailing list CentOS-mirror at centos.org http://lists.centos.org/mailman/listinfo/centos-mirror -------------------------------------------------------------------------------- _______________________________________________ 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/20130228/7a7c55fe/attachment-0006.html>