title: How can I check a file exists and execute a command if not?
body: <p>I have a daemon I have written using Python. When it is running, it has a PID file located at /tmp/filename.pid. If the daemon isn't running then PID file doesn't exist.</p>
  
  <p>On Linux, how can I check to ensure that the PID file exists and if not, execute a command to restart it? </p>
  
  <p>The command would be</p>
  
  <pre><code>python daemon.py restart
  </code></pre>
  
  <p>which has to be executed from a specific directory.</p>