<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>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.&nbsp; I used to do it 
the same way until recently I discovered a utility called flock.&nbsp; You can 
either use it within your script or you could simply use a one liner in your 
crontab.&nbsp; I’ve included examples both ways.&nbsp; flock is provided by 
util-linux package</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here’s one way via CRON</DIV>
<DIV>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&gt;/var/lock/centos_mirror_sync</DIV>
<DIV>&nbsp;</DIV>
<DIV>And here’s the way I do with with a script, my cron entry looks like the 
following...</DIV>
<DIV>&nbsp;</DIV>
<DIV>0 */6 * * * /sbin/centos_mirror_sync &gt;&gt; 
/var/log/centos_mirror_sync.log 2&gt;&amp;1</DIV>
<DIV>&nbsp;</DIV>
<DIV>The script is at <A 
title=http://mirrors.ndchost.com/ndchost/scripts/rsync_mirror_script 
href="http://mirrors.ndchost.com/ndchost/scripts/rsync_mirror_script">http://mirrors.ndchost.com/ndchost/scripts/rsync_mirror_script</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>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.</DIV>
<DIV>&nbsp;</DIV>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">--<BR>Shaun 
Reitan<BR>Network Data Center Host, Inc.<BR>www.ndchost.com</DIV>
<DIV 
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV>&nbsp;</DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=Ryan@techbnc.org 
href="mailto:Ryan@techbnc.org">Ryan Becker</A> </DIV>
<DIV><B>Sent:</B> Thursday, February 28, 2013 11:11 AM</DIV>
<DIV><B>To:</B> <A title=centos-mirror@centos.org 
href="mailto:centos-mirror@centos.org">Mailing list for CentOS mirrors</A> 
</DIV>
<DIV><B>Subject:</B> Re: [CentOS-mirror] setup mirror and lock 
files</DIV></DIV></DIV>
<DIV>&nbsp;</DIV></DIV>
<DIV 
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<P>Sure thing, I'm not at the office right now but when I am I'll send it off to 
you.</P>
<DIV class=gmail_quote>On Feb 28, 2013 1:02 PM, "Tony Schliesser" &lt;<A 
href="mailto:tony@schliesser.org">tony@schliesser.org</A>&gt; wrote:<BR 
type="attribution">
<BLOCKQUOTE 
style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
class=gmail_quote>
  <DIV dir=ltr>Ryan - If you don't care to share your mirror script, I'd like to 
  see it. 
  <DIV>&nbsp;</DIV>
  <DIV>Thanks,</DIV>
  <DIV>Tony</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>
  <DIV style="FONT-FAMILY: arial,sans-serif; FONT-SIZE: 13px" dir=ltr>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: 
  <DIV>&nbsp;</DIV>
  <DIV>
  <DIV>if [ -f /var/lock/subsys/rsync_updates ]; then</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; echo "Updates via rsync already running."</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; echo "--ERROR: REPOSITORY SYNC ABORTED AT 
  `date`--"</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; exit 0</DIV>
  <DIV>fi</DIV></DIV>
  <DIV>&nbsp;</DIV>
  <DIV>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.</DIV>
  <DIV>&nbsp;</DIV></DIV></DIV></DIV>
  <DIV class=gmail_extra><BR><BR>
  <DIV class=gmail_quote>On Wed, Feb 27, 2013 at 8:42 PM, Jim Hartnett <SPAN 
  dir=ltr>&lt;<A href="mailto:mirrors@gawsolutions.us" 
  target=_blank>mirrors@gawsolutions.us</A>&gt;</SPAN> wrote:<BR>
  <BLOCKQUOTE 
  style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
  class=gmail_quote>Ok, I have the lock scripts setup and working, I think 
    we're ready to<BR>add our mirror.<BR><BR>(information repeated):<BR>
    <DIV><BR>mirror Url: <A href="http://mirrors.gawsolutions.us/centos" 
    target=_blank>http://mirrors.gawsolutions.us/centos</A><BR>bandwidth: 100 
    Mbps up/down unmetered transfer<BR>located in dallas, tx, usa<BR>Geeks at 
    Work Solutions<BR>centos machine with apache<BR>rsync twice a day at offset 
    minutes (reduces peak for even hour starts)<BR><BR></DIV><SPAN><FONT 
    color=#888888>- -Jim<BR></FONT></SPAN><BR>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<BR>
    <DIV>
    <DIV><BR>_______________________________________________<BR>CentOS-mirror 
    mailing list<BR><A href="mailto:CentOS-mirror@centos.org" 
    target=_blank>CentOS-mirror@centos.org</A><BR><A 
    href="http://lists.centos.org/mailman/listinfo/centos-mirror" 
    target=_blank>http://lists.centos.org/mailman/listinfo/centos-mirror</A><BR></DIV></DIV></BLOCKQUOTE></DIV>
  <DIV>&nbsp;</DIV></DIV></BLOCKQUOTE></DIV>
<P>
<HR>
_______________________________________________<BR>CentOS-mirror mailing 
list<BR>CentOS-mirror@centos.org<BR>http://lists.centos.org/mailman/listinfo/centos-mirror<BR></DIV></DIV></DIV></BODY></HTML>