Running CRON without CLI

Running CRON without CLI

by Alan Kmiecik -
Number of replies: 6

I read through https://moodle.org/mod/forum/discuss.php?d=405523

Got to the post way down about running terminal to see if PHP is CLI and got this on my server (Bluehost):

PHP 7.3.30 (cgi-fcgi) (built: Aug 31 2021 18:30:18)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.30, Copyright (c) 1998-2018 Zend Technologies
with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd

So, no CLI (right?)

when I run this command:

/usr/local/bin/ea-php74 /home1/accountinfo/public_html/moodle/admin/cron.php

on the minute, I get emails that read:

ERROR: This script no longer supports CLI, please use admin/cli/cron.php instead

when I run this command (added CLI folder):

/usr/local/bin/ea-php74 /home1/accountinfo/public_html/moodle/admin/cli/cron.php

I get nuthin.

any thoughts?
Average of ratings: -
In reply to Alan Kmiecik

Re: Running CRON without CLI

by Ken Task -
Picture of Particularly helpful Moodlers

qualifications for this response: none ... I don't host with Bluehost. but ...
https://www.bluehost.com/help/article/setup-remove-or-edit-a-cron-job

The admin/cron.php is meant to be run via a web browser and not command line.
The admin/cli/cron.php IS the one you want to set up in cron.  That is command line only.

This PHP 7.3.30 (cgi-fcgi)  is the web based PHP ... the  (cgi-fcgi) tells you that.

Wrong path to php 7.3.30 on your system.
This: /usr/local/bin/ea-php74 shows you are trying to use 'Easy Apache' 7.4 ... not 7.3.30.

Good thing you have terminal to test ... first location of 7.3.30 cli;

First, in Moodle go to Site Admin menu, Server, phpinfo.
In the phpinfo page see what version of php moodle is running under.   It's that version you want to run the admin/cli/cron.php script in cron setup.

Discovery from command line:

Type: which php

That should show a path to a php cli.  On your system might show more than one.

Use the full path you see in what which php returned for the following command to check:

/path/to/php -v (the -i is asking information)

In your case, a guess:

/usr/local/bin/ea-php73/bin/php -v

If that is the php-cli for php 7.3.30, version information will show a (cli) on the top line of what it returns.

Clip: PHP 7.3.30 (cli)

Then you know what path to php you need to enter into the beginning of your cron setup.   Must use

/home1/accountinfo/public_html/moodle/admin/cli/cron.php

So the whole thing might look like:

/usr/local/bin/ea-php73/bin/php /home1/accountinfo/public_html/moodle/admin/cli/cron.php

Running that from command line first to make sure it's correct.
If so, one will see a screen that scrolls all the cron jobs/task it runs and at the end something like:


Cron script completed correctly
Cron completed at 11:45:40. Memory used 19.1MB.
Execution took 0.073005 seconds


If you need further assistance, contact Bluehost Technical Support.

'SoS', Ken

In reply to Ken Task

Re: Running CRON without CLI

by Alan Kmiecik -
Moodle shows PHP 7.4.23.
Cpanel, under MultiPHP Manager says the domain is ea-php74 but the System PHP Version is ea-php73.

So I changed the ea-php74 to ea-php73 and ran /usr/local/bin/ea-php73 /home1/accountinfo/public_html/moodle/admin/cli/cron.php

Now my each minute cron email reads:

Server Time: Wed, 15 Sep 2021 14:44:01 -0400

Execute scheduled task: Automated backups (core\task\automated_backup_task)
... started 14:44:02. Current memory use 18.9MB.


BUT, email registration does not register user and registration emails are not coming through. Email test does come through.  I do check spam and junk

I may have messed up the signup.php page (New account (saintsimon.site)

Bluehost support has been great for me, except for this. I've been through four different sessions and nobody seems to know much about CLI or Moodle CRON
In reply to Alan Kmiecik

Re: Running CRON without CLI

by Alan Kmiecik -
Just discovered my system is missing standard CAS from the disk. 

Copied the folder Auth > CAS folder from Moodle download to production.  Didn't help
In reply to Alan Kmiecik

Re: Running CRON without CLI

by Ken Task -
Picture of Particularly helpful Moodlers

"Bluehost support has been great for me, except for this. I've been through four different sessions and nobody seems to know much about CLI or Moodle CRON"

When one decides to run a moodle one has signed on to know something of server admin ... regardless of how hosted (with whom) or upon what OS.

So the Bluehost url on setting up cron was of no help either.

I'll state again that I don't host with BlueHost.

So, your Moodle phpinfo says you are running PHP 7.4.  Then the paths should be set to that version.   Check in Easy Apache for 7.4 IF the php extension for CLI is active.

So ... in doing google search for info for ya ..

I can find from Bluehost pages that show customer accessing WebHosting Management for setup of Easy Apache????

Do you have a WHM url and credentials to access.

https://www.bluehost.com/hosting/help/2466

Also, is your site running https vs http?   Should be running https.

Back to discovery now ...

from terminal session, type:

find / -name php

That might take some time to complete and show serveral 'hits'.

The one you are looking for is related to PHP 7.4.

Do above and share back.

Also ... one thing at a time ... we get cron running under the correct version ... then address smtp relay ... see you were also missing some core code for CAS?

'SoS', Ken



In reply to Ken Task

Re: Running CRON without CLI

by Alan Kmiecik -
Summary (for now):

Even though Moodle and mulitPHP Management show ea-php74, it works with the ea-php73.
I image that missing CAS was an issue.
I did mess up the signup.php file with my edits. Went back to original signup.php and it worked.

Thank you Ken for you help, it's really appreciate it.

Will update when I figure out which of my edits to signup.php.

ps. Since we have Bluehost plastered all over this thread, as of today, their shared hosting plans do not provide SQL 7 so you're limited to Moodle 3.9.   Love them for my Wordpress sites, I'm sure there are better for Moodle.