Cron fails with fatal php error

Hello guys,

After running like a charm for many months, for some reason my cron job entry disappeared off my cpanel. After re-entering the following;

          • cd /home/myfolder/public_html/crm; php -f cron.php > /dev/null 2>&1
            

and various iterations of it, I keep getting the following error in error.log for each schedule job it seems.

[11-Apr-2023 23:02:01 UTC] PHP Warning: ini_set(): Headers already sent. You cannot change the session module’s ini settings at this time in /home/myfolder/public_html/crm/include/entryPoint.php on line 169
[11-Apr-2023 23:02:01 UTC] PHP Warning: ini_set(): Headers already sent. You cannot change the session module’s ini settings at this time in /home/myfolder/public_html/crm/include/entryPoint.php on line 170
[11-Apr-2023 23:02:01 UTC] PHP Fatal error: Uncaught Exception: cron.php is CLI only. in /home/myfolder/public_html/crm/include/utils.php:1978
Stack trace:
#0 /home/myfolder/public_html/crm/cron.php(52): sugar_die(‘cron.php is CLI…’)
#1 {main}
thrown in /home/myfolder/public_html/crm/include/utils.php on line 1978

Can anyone help decipher what is going on please.

Running Suitecrm 7.130

Thanks Terry

Hey
this post might help you

it would be nice to understand where that error is coming from.

I suggest removing the cron entry you made. I think your error will still occur. And I suspect this is because something else is calling cron.php via the web server (some web service like easycron), or something that your hosting cooked up.

Thanks abuzarfaris, however I don’t have a legacy folder in my installation, so I fail to see how this would work. Besides, my cron has been working previously.

Hi pgr, I removed the cron entry from the server, no errors occur.

As soon as I put the cron entry back, the error (as per first post) occurs for each schedule job that is to be executed ‘as often as possible’.

This is a mystery to me, so any help understanding what is causing this is appreciated.

Terry

The “public/legacy” folder is for v8 installations.

If you’re entering the cron schedule through Cpanel, it seems that CPanel is not behaving normally and calling cron through the command-line. Maybe they have a new version and it changed something.

The code tests this:

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

You can try printing that value and seeing what it contains, replace all that code above (in cron.php at the root of your SuiteCRM installation) with this:

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

And then make the error appear again and tell us what you see.

Thanks pgi for looking into this.

Here’s the result…

[12-Apr-2023 21:53:02 UTC] PHP Warning: ini_set(): Headers already sent. You cannot change the session module’s ini settings at this time in /home/terryl/public_html/crm/include/entryPoint.php on line 169
[12-Apr-2023 21:53:02 UTC] PHP Warning: ini_set(): Headers already sent. You cannot change the session module’s ini settings at this time in /home/terryl/public_html/crm/include/entryPoint.php on line 170
[12-Apr-2023 21:53:02 UTC] PHP Fatal error: Uncaught Exception: cron.php is CLI only, got cgi-fcgi instead. in /home/terryl/public_html/crm/include/utils.php:1978
Stack trace:
#0 /home/terryl/public_html/crm/cron.php(57): sugar_die(‘cron.php is CLI…’)
#1 {main}
thrown in /home/terryl/public_html/crm/include/utils.php on line 1978

So the question is, what is cgi-fcgi ?? I see it’s some kind of bridge from CGI to FastCGI.

Terry

Update…

Got in touch with my hosting people to ask if anything had changed and explained that php_sapi_name was now returning cgi-fcgi instead of cli.

A few hours later, it’s all running again and I notice they changed the cron entry to;

/usr/local/bin/php -f /home1/terryl/public_html/crm/cron.php > /dev/null 2>&1

They didn’t elaborate whether they had changed anything other than this.

Thanks pgi, really appreciate your assistance.

Terry

1 Like