title: Pid file and prevent a duplicate instance from running?
body: <p>I found the following lines at the top of one of our scripts. I understand that it verifies if the PID file is already running it will kill the script to run twice, but I don't really understand what each statement does? </p>
  
  <p>For example, <code>if kill -0 &amp;&gt;1 &gt; /dev/null $pid; then</code>. Can someone help me understanding the logic behind this?</p>
  
  <pre><code>pidfile=/tmp/backup_meb.pid
  if [ -e $pidfile ]; then
      pid=`cat $pidfile`
      if kill -0 &amp;&gt;1 &gt; /dev/null $pid; then
          echo "Already running"
          exit 1
      else
          rm $pidfile
      fi
  fi
  echo $$ &gt; $pidfile
  </code></pre>