cron.php is CLI only

Hi everyone,

I am working through a clean installation of SuiteCRM 7.11.0 on a Linux based server. I followed the instructions on setting cron for cron.php. The problem is that it returns with ‘cron.php is CLI only’. Server configuration is as follows:

OS: Linux x86_64
PHP: 7.2
Apache: 2.4.37
MySQL: 10.2.19-MariaDB-log-cll-lve
Perl: 5.10.1

Installation went okay with a few errors and known issues that I am currently working through.

Any ideas for the cron.php error? Thanks in advance.

Kind regards
David

@limagedigitale exactly how did you set up the jobs? If you used the normal crontab way, then that is CLI, so you won’t get that error.

If you choose the EasyCron way (which I don’t recommend…) then that is not CLI, it’s web server PHP, so you would get that error. But the tutorial includes instructions to avoid that.

Hi pgr,
I followed the instructions given in the installation guide, except that I used ‘crontab -e’ rather than ‘sudo crontab -e -u limagene’. I ran cron.php using ‘php -f cron.php’ from the SuiteCRM directory as would be run by the command for cron ‘cd /home/limagene/public_html/SuiteCRM_dir; php -f cron.php’. I have attached a capture from error_log.
Any ideas? Thanks.
David

That doens’t make much sense to me, sorry…

First, don’t skip the user name part when editing the crontab. There are many different crontabs, one for each user, and sometimes also a system-wide crontab. The matter of which user is running your cron.php is not a small one - SuiteCRM will break in unexpected ways if cron is running as root, touching files and breaking their permissions for the regular users.

Second, if you are running from a command-line PHP, that is CLI. I can’t imagine why your PHP would be complaining.

If you can’t get around this, you can always comment that CLI check in the PHP file. It is merely a security check, so that people don’t call your cron.php from your web server. But that is highly unlikely to ever be attempted, and can be prevented in other ways.

1 Like

Hi pgr,

My SuiteCRM install is on my web hosting account where I have only basic user privileges. The Linux system that my web host uses does not support sudo. I would think that as an ordinary Linux user I should be ale to run ‘crontab -e’ instead of ‘crontab -e -u limagene’ (which won’t run as I am not a privileged user). I couldn’t change group ownership of the SuiteCRM directory as I am not allowed. The other commands (chmod) were done as a normal user and config_override.php does not exist until the installation is completed. I changed the mode of config_override.php as soon as it was available.

The line in the cron file shown earlier is only to show the structure of the command. I have the actual path to the SuiteCRM install in my cron file.

This is the curious bit, why is cron.php not reporting that I am running in CLI when I call it from command-line PHP?

Anyway, I will try your suggestion of commenting out the check for CLI and see how it goes. Thanks.

David

@limagedigitale
Hi Also my hosting don’t admit cron , so I can to replace scheduling a calling of php file.
Have you find a solution
I s there a way for create a php file that made same thing as cron?
Thanks
FAbio

1 Like

I don’t understand the security risk of a cron job being run from the outside, but all you have to do is comment out that line in cron.php in your main suitecrmfolder so it looks like this, and then your server could run it or you could run it manually from your browser to test that your schedulers are running.

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

To test what the API Type was I did this and looked at the output from the browser and also output in my email when run from the server. It was both cgi.

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