<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20315">
<style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst, 
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle, 
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;"><div>Actually, you don't have to manually remove the lock file. See the “trap” statement in bash:</div><div><br></div><div><a href="http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files">http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files</a></div><div><a href="http://bash.cyberciti.biz/guide/Trap_statement" target="_parent">http://bash.cyberciti.biz/guide/Trap_statement</a></div><div><br></div><div>You can take action when a signal is received, including cleaning up a lock file. It's good practice to use trap to clean up after yourself in scripts.</div><div><br></div><div data-signatureblock="true"><br></div><div style="padding-top: 5px; border-top-color: rgb(229, 229, 229); border-top-width: 1px; border-top-style: solid;"><div><font face=" 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif'" style='line-height: 15pt; letter-spacing: 0.02em; font-family: "Calibri", "Segoe UI", "Meiryo", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "sans-serif"; font-size: 12pt;'><b>From:</b> <a href="mailto:mglaske@gmail.com" target="_parent">Michael Glaske</a><br><b>Sent:</b> ‎Tuesday‎, ‎December‎ ‎24‎, ‎2013 ‎9‎:‎25‎ ‎AM<br><b>To:</b> <a href="mailto:grlug@grlug.org" target="_parent">Mailing List for LUG in greater Grand Rapids, MI area.</a></font></div></div><div><br></div><div dir=""><div dir="ltr">Pretty easy to implement in bash or sh..  The only problem is, if you Crtl-C out of it, you'll have to manually remove the lock file.<div><br></div><div>if [ -f /var/run/script.lock ]; then</div><div>     print "Already running..  Exiting"</div>

<div>     exit 1</div><div>fi</div><div><br></div><div>date > /var/run/script.lock</div><div><br></div><div># put your script here</div><div><br></div><div># at the end</div><div>rm -f /var/run/script.lock</div></div>
<div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Dec 24, 2013 at 9:17 AM, Eric Beversluis <span dir="ltr"><<a href="mailto:ebever@researchintegration.org" target="_parent">ebever@researchintegration.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">I've got a backup program on a server that includes a mysqldump once a<br>
day which overwrites the existing sysmyqldump.sql. The script also does<br>
rsync (of zarafa-backup, the mysqldump, and /var/lib/zarafa (the zarafa<br>
attachments file) to an external hard drive. Once a month is also copies<br>
the sysmysqldump.sql that's on the external HDD to a file with that<br>
day's date attached.<br>
<br>
The cron is set to run every hour. Right now, mysqldump is finishing at<br>
40 min past the hour (00:40), so I think that when it also tries to make<br>
the copy on the 1st of the month it will run over into the next hour.<br>
<br>
As I understand it, the thing to do to prevent the script starting over<br>
before the old one finishes is to use 'flock.'<br>
<br>
My question is this: How does cron respond if flock prevents the script<br>
from starting at 01:00? Does it start it when the flock is freed or just<br>
skip that cycle or what?<br>
<br>
Thanks.<br>
<br>
_______________________________________________<br>
grlug mailing list<br>
<a href="mailto:grlug@grlug.org" target="_parent">grlug@grlug.org</a><br>
<a href="http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug" target="_parent">http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug</a><br>
</blockquote></div><br></div>
</div></div>
</body>
</html>