Cron.php undefined index 'SCRIPT_FILENAME'
As mam08ixo has stated certain _SERVER
properties are available on the CLI, however, due to some abnormal configuration I solved this by using php-cli
:
php-cli /home/***/public_html/cron.php > /dev/null &2>1
This is what worked for me:
php -f /home/USERNAME/www/cron.php >/dev/null 2>&1
And I had to modify cron.php, just use
$isShellDisabled = true;
instead of
$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;
Reference: http://support.xtento.com/wiki/Setting_up_the_Magento_cronjob
I kept getting Undefined index in my error log but it was working. However, to make it better, I initialized the variables in cron.php to remove the errors. Like so:
$_SERVER['SCRIPT_NAME'] = '';
$_SERVER['SCRIPT_FILENAME'] = '';
How come you "ultimately" think that the $_SERVER
execution(!) environment information is not available when running scripts via CLI?
The PHP language reference contains some hints and comments that it actually does. Also, on any machine in my sphere, $_SERVER
is populated just fine. So if you get an undefined index notice, it's most likely due to some specialties with your environment rather than a general fail in cron.php
.
Pay special attention to the variables_order
setting.
Appendix: You might want to regard $_SERVER
as information acquired from the serving entity. May it be shell, mod_php, fastcgi, or whatever. That's why the contents (keys) of the variable depend on the current environment. Bottom line is, $_SERVER
is NOT only populated when served via webserver.