title: Running php from cron did not run as CLI
body: <p>I noticed this problem after a php script ran from cron started to timeout but it was not an issue when it was ran manually from command line. (PHP has max_execution_time is 0 for CLI by default)</p>
  
  <p>So I tried to run a simple cron such:</p>
  
  <pre><code>50 8 * * * php -q /tmp/phpinfo.php &gt; /tmp/phpinfo
  </code></pre>
  
  <p>The script would just call phpinfo().</p>
  
  <p>Surprisingly it wrote out phpinfo in html format, which suggested that it was not run as CLI. And max_execution_time was 30 in the output.</p>
  
  <p>Running the script manually from command line such</p>
  
  <pre><code>php -q /tmp/phpinfo.php | less
  </code></pre>
  
  <p>wrote out the php info in text format and max_execution_time was 0 in the output.</p>
  
  <p>I know there must be a configuration issue somewhere, but I just could not find where the problem is. This is happening on a production server, which I have a complete control of. Running the same script from cron on my development machine worked fine.</p>
  
  <p>Here is the summary of the difference</p>
  
  <pre><code>function             | CLI                     | cron                   |
  php_sapi_name        | cli                     | cgi-fcgi               |
  php_ini_loaded_file  | /usr/local/lib/php.ini  | /usr/local/lib/php.ini | 
  </code></pre>