<div dir="ltr">SOP is to write the actual PID of the running process into the pidfile,
then check to a) that the pidfile exists, and b) that the process
referenced in the pidfile exists.  if the pidfile exists, but the
process does not, take over the pidfile and carry on.<br>
<br><div class="gmail_quote">On Fri, Aug 29, 2008 at 9:51 AM, Heston James <span dir="ltr"><<a href="mailto:heston_james@live.co.uk">heston_james@live.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>Good afternoon all.<br>
 <br>
I have an application/script which is launched by crontab on a regular basis. I need an effective and accurate way to ensure that only one instance of the script is running at any one time.<br>
 <br>
After a short look around the internet I found a couple of examples, such as this one (<a href="http://code.activestate.com/recipes/474070/" target="_blank">http://code.activestate.com/recipes/474070/</a>), however they both seem to be focused on a windows based environment.<br>

 <br>
Can anyone offer their advice on how best to do this on a linux based system?<br>
 <br>
I have been contemplating the idea of creating a pidfile which is destroyed at the end of the script, will this suffice? is it fool proof? My only concern with this is that if the script crashes or is stopped halfway through processing for whatever reason, I'll be left with a dead pidfile on the system and no successive runs will work.<br>

 <br>
I'm really interested to get your ideas guys, Thanks.<br>
 <br>
Heston<br><br><hr>Get Hotmail on your mobile from Vodafone  <a href="http://clk.atdmt.com/UKM/go/107571435/direct/01/" target="_blank">Try it Now!</a></div>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br></div>