<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to secure only one running instance of Linux script?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">So I am trying to get one of my scripts in pfSense to only start once so to speak, just as a precaution. Normal mode would be it starts itself automatic, and well that's just enough. However I like to double check that it is not already running. So I though I code it like:</p>
<pre><code>running=$(ps aux | grep CheckIfHome.sh | grep -v grep | grep -o CheckIfHome.sh | wc -l);

if [ $running &gt; 1 ];
then
  exit
fi
</code></pre>
<p dir="auto">But this will fail with "invalid variable" and for some reason my head seems to be on vacation…? Anyone that might help out?</p>
]]></description><link>https://forum.netgate.com/topic/125549/how-to-secure-only-one-running-instance-of-linux-script</link><generator>RSS for Node</generator><lastBuildDate>Sun, 15 Nov 2026 00:43:04 GMT</lastBuildDate><atom:link href="https://forum.netgate.com/topic/125549.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 10 Jan 2018 07:17:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to secure only one running instance of Linux script? on Thu, 11 Jan 2018 20:47:06 GMT]]></title><description><![CDATA[<p dir="auto">I ended up with something like this:</p>
<pre><code>
if [ `pgrep script.sh | wc -l` -gt 1 ];
then
  exit
fi
</code></pre>
]]></description><link>https://forum.netgate.com/post/745515</link><guid isPermaLink="true">https://forum.netgate.com/post/745515</guid><dc:creator><![CDATA[Bamsefar]]></dc:creator><pubDate>Thu, 11 Jan 2018 20:47:06 GMT</pubDate></item><item><title><![CDATA[Reply to How to secure only one running instance of Linux script? on Wed, 10 Jan 2018 12:24:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">No need for anyone. Just one will and you'll be fine.<br />
What about this one : <a href="https://www.google.fr/search?q=shell+script+run+one+instance+&amp;ie=utf-8&amp;oe=utf-8&amp;client=firefox-b&amp;gfe_rd=cr&amp;dcr=0&amp;ei=pAVWWvD7F--3tgeTyZyQAg" target="_blank" rel="noopener noreferrer nofollow ugc">shell script run one instance</a>  ;)</p>
]]></description><link>https://forum.netgate.com/post/745146</link><guid isPermaLink="true">https://forum.netgate.com/post/745146</guid><dc:creator><![CDATA[Gertjan]]></dc:creator><pubDate>Wed, 10 Jan 2018 12:24:47 GMT</pubDate></item></channel></rss>