title: shell script to monitor php process
body: <p>How can I auto restart a process when it is dead?</p>
  
  <p>I am currently doing it like this:</p>
  
  <pre><code>#!/bin/bash
  while true;do
      ps -aux 2&gt;/dev/null |grep redis_subscribe|grep -v grep &gt;/dev/null
      if [ $? -ne 0 ];then
          php /data/www/wwwroot/app.eclicks.cn/oil/index.php public/redis_subscribe subscribe   2&gt;&amp;1 &gt;&gt;/data/cilogs/manitor/image_upload.log &amp;
      fi;
      sleep 10;
  done;
  </code></pre>