<?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>Sat, 04 Sep 2010 18:41:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
		<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>
