Old cron bug still present in SuiteCRM

The cron.php is CLI only error is still present in SuiteCRM

The workaround seems to still work though as outlined here.

Hi brucelewin,

I am not totally convinced that this is a bug. The code is there so that people cannot fire your cron jobs by hitting that file from the browser. I only disable that line to allow browser access when I want to run the cron script with a step through debugger. I have also changed cron.php as follows to add entries to sugarcrm.log so I can see what is happening.



$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != 'cli') {
    sugar_die("cron.php is CLI only.");


$sapi_name = php_sapi_name();
$GLOBALS['log']->debug("Detected sapi_name as '$sapi_name'");
$sapi_type = substr($sapi_name, 0, 3);
$GLOBALS['log']->debug("Detected sapi_type as '$sapi_type'");
if ($sapi_type != 'cli') 
    $GLOBALS['log']->debug("cron.php died with error 'cron.php is CLI only.'.");
    sugar_die("cron.php is CLI only.");

I am on a windows server so the scheduler runs the following batch file every 5 minutes. Some of the steps may be overkill, but it does work as expected.

set logFileName=D:\logs\beyond_crm_%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%.log
echo === Start %DATE% %TIME% >> %logFileName% 2>&1
D: >> %logFileName% 2>&1
cd D:\Inetpub\wwwroot\beyond_crm >> %logFileName% 2>&1
D:\PHP_5.5.8\php.exe -f cron.php >> %logFileName% 2>&1
echo === End %DATE% %TIME% >> %logFileName% 2>&1

On a *nix system, you could run a similar shell script from cron itself.



Point taken… I think I have to edit the cron file because when I do run it from the command line, it fails due to various permission problems. Everything’s set to 777 but it may be due to shared hosting, I don’t know?