I suspect your problem lies in the missing environment variable, namely the important $PATH . When you run this:
php -q /tmp/phpinfo.php
the system should decide which program you mean by php . He does this by looking, in order, through the directories in the current $PATH environment variable.
Executed from a normal shell, your environment is configured in such a way that it finds the CLI version of PHP, as you expect.
However, when cron executes the command, it does this without any environment variables that will be configured by your interactive shell. Since your system may have other executables, called php , for different "SAPIs", it may choose "incorrect" - in your case, the cgi-fcgi , in accordance with the message you output from php_sapi_name() .
To fix this, first find the path to the correct php executable in the normal shell by typing this:
which php
This should give you a path like /usr/bin/php . You can go ahead and check if this is a "symbolic link" pointing to a different file name:
ls -l $(which php)
(you will see an arrow on the output if there is one, for example /usr/bin/php -> /usr/bin/php5-cli )
Then, take this full path to the PHP executable and use it in your crontab entry so that it looks something like this:
50 8 * * * /usr/bin/php5-cli -q /tmp/phpinfo.php > /tmp/phpinfo
IMSoP source share