<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: One instance at a time with PID file in Bash</title>
	<atom:link href="http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/</link>
	<description>Please excuse the ugliness of this site. Just remember, as McCoy said to Kirk so many times, &#34;D*&#38;@!$ Jim! I&#039;m an engineer, not a web designer!&#34;</description>
	<lastBuildDate>Mon, 10 Oct 2011 22:00:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Craig</title>
		<link>http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/comment-page-1/#comment-18392</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Wed, 11 May 2011 14:09:17 +0000</pubDate>
		<guid isPermaLink="false">http://candrews.integralblue.com/?p=37#comment-18392</guid>
		<description>You should also check if they process_id that is running is actually the same script. The system could release the script and then re-issue that process_id to another program.</description>
		<content:encoded><![CDATA[<div class='microid-mailto+http:sha1:98e8a18024fa2942bfadd9871e4be10b6c2ac56e'>You should also check if they process_id that is running is actually the same script. The system could release the script and then re-issue that process_id to another program.</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharad Agarwal</title>
		<link>http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/comment-page-1/#comment-94</link>
		<dc:creator>Sharad Agarwal</dc:creator>
		<pubDate>Sat, 11 Sep 2010 16:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://candrews.integralblue.com/?p=37#comment-94</guid>
		<description>Maybe we can try to modify your run_one_instance.sh script a bit to make it so that the  can be any other script?

No copy/paste that way, and makes it more interesting :-)</description>
		<content:encoded><![CDATA[<div class='microid-mailto+http:sha1:e7f38f333874987eee2893a556bb381b29292d9b'>Maybe we can try to modify your run_one_instance.sh script a bit to make it so that the  can be any other script?</p>
<p>No copy/paste that way, and makes it more interesting <img src='http://candrews.integralblue.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/comment-page-1/#comment-89</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Sat, 28 Aug 2010 02:06:03 +0000</pubDate>
		<guid isPermaLink="false">http://candrews.integralblue.com/?p=37#comment-89</guid>
		<description>Hi, 

Your syntax is a bit wrong, when I ran the command the output of kill got redirected to the file 1.

Here is the syntax that worked for me:

if kill -0 $pid &gt; /dev/null 2&gt;&amp;1; then
echo &quot;Already running&quot;
exit 1
else
rm $pidfile
fi
fi
echo $$ &gt; $pidfile</description>
		<content:encoded><![CDATA[<div class='microid-mailto+http:sha1:6237c32ab454494a25b3a1caf834070c909e1c76'>Hi, </p>
<p>Your syntax is a bit wrong, when I ran the command the output of kill got redirected to the file 1.</p>
<p>Here is the syntax that worked for me:</p>
<p>if kill -0 $pid &gt; /dev/null 2&gt;&amp;1; then<br />
echo &#8220;Already running&#8221;<br />
exit 1<br />
else<br />
rm $pidfile<br />
fi<br />
fi<br />
echo $$ &gt; $pidfile</p></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerard Seibert</title>
		<link>http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/comment-page-1/#comment-62</link>
		<dc:creator>Gerard Seibert</dc:creator>
		<pubDate>Mon, 30 Nov 2009 12:18:16 +0000</pubDate>
		<guid isPermaLink="false">http://candrews.integralblue.com/?p=37#comment-62</guid>
		<description>I modified your script slightly. It works on Bash and does not create a &#039;1&#039; file. Using the &#039;f&#039; flag with &#039;rm&#039; also prevents useless error messages.

PID_FILE=&quot;/var/run/my_prog.pid&quot;

## Check to see if the program is running
if [[ -e ${PID_FILE} ]]; then
## Capture the &#039;pid&#039; number in &#039;pid&#039; variable
  pid=$( ${PID_FILE}

do something

## Remove the pid file if it exists
if [[ -e ${PID_FILE} ]]; then
  rm -f ${PID_FILE}
fi</description>
		<content:encoded><![CDATA[<div class='microid-mailto+http:sha1:444a3d61ec7ff7182bb81b4a30781179848c80c5'>I modified your script slightly. It works on Bash and does not create a &#8217;1&#8242; file. Using the &#8216;f&#8217; flag with &#8216;rm&#8217; also prevents useless error messages.</p>
<p>PID_FILE=&#8221;/var/run/my_prog.pid&#8221;</p>
<p>## Check to see if the program is running<br />
if [[ -e ${PID_FILE} ]]; then<br />
## Capture the &#8216;pid&#8217; number in &#8216;pid&#8217; variable<br />
  pid=$( ${PID_FILE}</p>
<p>do something</p>
<p>## Remove the pid file if it exists<br />
if [[ -e ${PID_FILE} ]]; then<br />
  rm -f ${PID_FILE}<br />
fi</p></div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samat Jain</title>
		<link>http://candrews.integralblue.com/2009/02/one-instance-at-a-time-with-pid-file-in-bash/comment-page-1/#comment-2</link>
		<dc:creator>Samat Jain</dc:creator>
		<pubDate>Mon, 16 Feb 2009 23:56:39 +0000</pubDate>
		<guid isPermaLink="false">http://candrews.integralblue.com/?p=37#comment-2</guid>
		<description>Related and probably interesting to you: over at the sysadvent log there&#039;s an article on &lt;a href=&quot;http://sysadvent.blogspot.com/2008/12/day-9-lock-file-practices.html&quot; rel=&quot;nofollow&quot;&gt;best lockfile practices&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<div class='microid-mailto+http:sha1:1144944ba14720f02a4a9989a774b1dca8b647d5'>Related and probably interesting to you: over at the sysadvent log there&#8217;s an article on <a href="http://sysadvent.blogspot.com/2008/12/day-9-lock-file-practices.html" rel="nofollow">best lockfile practices</a>.</div>
]]></content:encoded>
	</item>
</channel>
</rss>

