<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
I was just following the examples given in the manual, but, indeed,
your suggestion is very good. Thanks a lot!<br>
<br>
<br>
<pre class="moz-signature" cols="72"> Jonny
--
João Carlos Mendes Luís - Computer & Networking Engineer
<a class="moz-txt-link-abbreviated" href="mailto:jonny@jonny.eng.br">jonny@jonny.eng.br</a>
</pre>
<br>
On 07/14/2011 08:36 PM, Kealey, Martin, VF-NZ wrote:
<blockquote
cite="mid:D51B7F4A07B18443BD02BBC35FA2899F9392F46C@VFNZ-MSX06.vf-nz.internal.vodafone.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:Consolas;}
kbd
{mso-style-priority:99;
font-family:Consolas;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:1.0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
tt
{mso-style-priority:99;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";
color:black;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Times New Roman","serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);">Perhaps that example code would clearer
if written:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<pre><span lang="LA">(</span><o:p></o:p></pre>
<pre> <span lang="LA">if ! flock -w 1 200 ; then</span><o:p></o:p></pre>
<pre> <span lang="LA">echo >&2 "</span>Another process is still running<span lang="LA">..."</span><o:p></o:p></pre>
<pre> <span lang="LA">exit</span><o:p></o:p></pre>
<pre> <span lang="LA">fi</span><o:p></o:p></pre>
<pre> <span lang="LA">RunLocked</span><o:p></o:p></pre>
<pre><span lang="LA">) 200> ${lockdir}/mirror.centos.lock<o:p></o:p></span></pre>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);">Or<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<pre><span lang="LA">exec 200> ${lockdir}/mirror.centos.lock<o:p></o:p></span></pre>
<pre>if ! flock -w 1 200 ; then<o:p></o:p></pre>
<pre> echo >&2 "Another process is still running..."<o:p></o:p></pre>
<pre> exit<o:p></o:p></pre>
<pre>fi<span lang="LA"><o:p></o:p></span></pre>
<pre><span lang="LA">RunLocked<o:p></o:p></span></pre>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);">Or for a more succinct version:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<pre><span lang="LA">( flock -w 1</span><span lang="LA"> </span><span lang="LA">200 && RunLocked ) 200> $</span>{<span lang="LA">lockdir</span>}<span lang="LA">/mirror.centos.lock</span><o:p></o:p></pre>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);">(Point is: referencing “</span><code><span
style="font-size: 10pt;" lang="PL">$?</span></code><span
style="font-size: 11pt; color: rgb(31, 73, 125);">” is
almost never needed, and usually obfuscatory.)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; color:
rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div>
<div style="border-right: medium none; border-width: 1pt
medium medium; border-style: solid none none; border-color:
rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color;
padding: 3pt 0cm 0cm;">
<p class="MsoNormal"><b><span style="font-size: 10pt;
font-family:
"Tahoma","sans-serif"; color:
windowtext;" lang="EN-US">From:</span></b><span
style="font-size: 10pt; font-family:
"Tahoma","sans-serif"; color:
windowtext;" lang="EN-US">
<a class="moz-txt-link-abbreviated" href="mailto:centos-mirror-bounces@centos.org">centos-mirror-bounces@centos.org</a>
[<a class="moz-txt-link-freetext" href="mailto:centos-mirror-bounces@centos.org">mailto:centos-mirror-bounces@centos.org</a>] <b>On Behalf
Of </b>João Carlos Mendes Luís<br>
<b>Sent:</b> 13 July 2011 03:29<br>
<b>To:</b> Mailing list for CentOS mirrors.<br>
<b>Subject:</b> Re: [CentOS-mirror] I see all your new
mirrors ...<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><tt><span style="font-size: 10pt;">Using
"touch" and "test -e"</span></tt> as a lock test is not
safe. If the shell dies for any reason, the lock file will
get stale.<br>
<br>
If you sync station is linux, a safer option is to use the
flock(1) program:<br>
<br>
<br>
<tt><b><span style="font-size: 10pt;">NAME</span></b></tt><b><span
style="font-size: 10pt; font-family: "Courier
New";"><br>
<tt> flock - Manage locks from shell scripts</tt><br>
<br>
<tt>SYNOPSIS</tt><br>
<tt> flock [-sxon] [-w timeout] lockfile [-c]
command...</tt><br>
<br>
<tt> flock [-sxon] [-w timeout] lockdir [-c]
command...</tt><br>
<br>
<tt> flock [-sxun] [-w timeout] fd</tt><br>
</span></b><br>
<br>
Here is the lock part of my mirror script:<br>
<br>
<tt><b><span style="font-size: 10pt;">RunLocked()</span></b></tt><b><span
style="font-size: 10pt; font-family: "Courier
New";"><br>
<tt>{</tt><br>
<tt> ....</tt><br>
<tt>}</tt><br>
<br>
<tt>(</tt><br>
<tt> flock -w 1 200</tt><br>
<tt> if [ "$?" -ne 0 ] ; then</tt><br>
<tt> echo "Error, lock is already taken..."</tt><br>
<tt> exit</tt><br>
<tt> else</tt><br>
<tt> RunLocked</tt><br>
<tt> fi</tt><br>
<tt>) 200> ${lockdir}/mirror.centos.lock</tt><br>
<br>
</span></b><br>
<br>
<o:p></o:p></p>
<pre><span lang="LA"> Jonny<o:p></o:p></span></pre>
<pre><span lang="LA"><o:p> </o:p></span></pre>
<pre><span lang="LA">-- <o:p></o:p></span></pre>
<pre><span lang="LA">João Carlos Mendes Luís - Computer & Networking Engineer<o:p></o:p></span></pre>
<pre><span lang="LA"><a moz-do-not-send="true" href="mailto:jonny@jonny.eng.br">jonny@jonny.eng.br</a><o:p></o:p></span></pre>
<p class="MsoNormal"><br>
On 07/12/2011 11:56 AM, Adam wrote: <o:p></o:p></p>
<p class="MsoNormal">admin wrote: <br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
Yes It would be great . I'm still rsync centos repo. <br>
Could you provide me bash script to rsync with file locking ?
<o:p></o:p></p>
<p class="MsoNormal"><br>
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. <br>
<br>
Adam <br>
<br>
<o:p></o:p></p>
<pre><span lang="LA"><o:p> </o:p></span></pre>
<pre><span lang="LA"><o:p> </o:p></span></pre>
<pre><span lang="LA">_______________________________________________<o:p></o:p></span></pre>
<pre><span lang="LA">CentOS-mirror mailing list<o:p></o:p></span></pre>
<pre><span lang="LA"><a moz-do-not-send="true" href="mailto:CentOS-mirror@centos.org">CentOS-mirror@centos.org</a><o:p></o:p></span></pre>
<pre><span lang="LA"><a moz-do-not-send="true" href="http://lists.centos.org/mailman/listinfo/centos-mirror">http://lists.centos.org/mailman/listinfo/centos-mirror</a><o:p></o:p></span></pre>
</div>
<div><font face="Arial"><font size="2">
<hr>
</font></font></div>
<div><font face="Arial"><font size="2">Have you seen our website?
.... </font><a moz-do-not-send="true"
href="http://www.vodafone.co.nz"><font size="2">www.vodafone.co.nz</font></a><font
size="2"> </font></font></div>
<div> </div>
<div><font face="Arial"><font size="2">Manage Your Account, check
your Vodafone Mail and send web2TXT online: </font><a
moz-do-not-send="true"
href="http://www.vodafone.co.nz/myvodafone"><font size="2">www.vodafone.co.nz/myvodafone</font></a></font></div>
<div><font face="Arial"> </font></div>
<hr>
<div><font face="Arial"><font size="1">CAUTION: This
correspondence is confidential and intended for the named
recipient(s) only. If you are not the named recipient and
receive this correspondence in error, you must not copy,
distribute or take any action in reliance on it and you
should delete it from your system and notify the sender
immediately. Thank you.</font></font></div>
<div> </div>
<div><font face="Arial" size="1">Unless otherwise stated, any
views or opinions expressed are solely those of the author and
do not represent those of Vodafone New Zealand Limited.</font></div>
<div> </div>
<div><font face="Arial" size="1"><strong>20 Viaduct Harbour
Avenue, Private Bag 92161, Auckland 1030<br>
Telephone + 64 9 355 2000<br>
Facsimile + 64 9 355 2001</strong></font></div>
<div>
<hr>
</div>
e>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
CentOS-mirror mailing list
<a class="moz-txt-link-abbreviated" href="mailto:CentOS-mirror@centos.org">CentOS-mirror@centos.org</a>
<a class="moz-txt-link-freetext" href="http://lists.centos.org/mailman/listinfo/centos-mirror">http://lists.centos.org/mailman/listinfo/centos-mirror</a>
</pre>
</blockquote>
</body>
</html>