cron not working on fresh installation (Moodle 3.7)

cron not working on fresh installation (Moodle 3.7)

by Stefan Schoch -
Number of replies: 9
Picture of Particularly helpful Moodlers

Hi there,

I have a fresh installation running that's working fine (everything looks great, messages are sent via Email) but nevertheless the server message says:

'The cli/cron.php maintenance script has not been run for at least 24 hours. '

I checked with my hosting provider, the cron job seems to tun correctly:

Line 3017: 109.237.138.50 - - [19/Oct/2019:09:35:01 +0200] "GET /admin/cli/cron.php HTTP/1.1" 200 63 "-" "Alfahosting GmbH - Cronservice" integraleimpulse.de
Line 3054: 109.237.138.50 - - [19/Oct/2019:09:40:02 +0200] "GET /admin/cli/cron.php HTTP/1.1" 200 63 "-" "Alfahosting GmbH - Cronservice" integraleimpulse.de
Line 3208: 109.237.138.50 - - [19/Oct/2019:09:45:00 +0200] "GET /admin/cli/cron.php HTTP/1.1" 200 63 "-" "Alfahosting GmbH - Cronservice" integraleimpulse.de
Line 3232: 109.237.138.50 - - [19/Oct/2019:09:50:01 +0200] "GET /admin/cli/cron.php HTTP/1.1" 200 63 "-" "Alfahosting GmbH - Cronservice" integraleimpulse.de
Line 3251: 109.237.138.50 - - [19/Oct/2019:09:55:00 +0200] "GET /admin/cli/cron.php HTTP/1.1" 200 63 "-" "Alfahosting GmbH - Cronservice" integraleimpulse.de


Any ideas or tipps?
Stefan

Average of ratings: -
In reply to Stefan Schoch

Re: cron not working on fresh installation (Moodle 3.7)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
GET? From another machine through the net? For that there is ./admin/cron.php.
In reply to Visvanath Ratnaweera

Re: cron not working on fresh installation (Moodle 3.7)

by Stefan Schoch -
Picture of Particularly helpful Moodlers
It's from my hoster, tha path seems correct, I checked the file cron.php is there.
In reply to Stefan Schoch

Re: cron not working on fresh installation (Moodle 3.7)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
What do you mean? That there is a file called ./admin/cli/cron.php? Sure there is one! The question is, whether it is the right one. Did you read inside? Compare it with ./admin/cron.php.

Hint. CLI stands for Command Line Interface.
wink
In reply to Visvanath Ratnaweera

Re: cron not working on fresh installation (Moodle 3.7)

by Stefan Schoch -
Picture of Particularly helpful Moodlers
Ok, now I understand: there's a difference in the scripts depending from where they are called.

I now changed the system to call the admin/cron.php with a password.
Will see if that works.

Is there any log-file where I can check the chron activities (in addition to 'Site administration/ Notifications')?

Having some trouble with my hosting provider around cron jobs sometimes and the whole system is quite intransparent for me.

Stefan
In reply to Stefan Schoch

Re: cron not working on fresh installation (Moodle 3.7)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You wrote:
> there's a difference in the scripts depending from where they are called.

There are two scripts, each for a different purpose.

> Is there any log-file where I can check the chron activities (in addition to 'Site administration/ Notifications')?

Since you call the web-based cron, it will be logged in the web server's logs. Your hosting provider should know.

> Having some trouble with my hosting provider around cron jobs sometimes and the whole system is quite intransparent for me.

That is why people go to providers who specialize on Moodle!
Average of ratings: Useful (1)
In reply to Stefan Schoch

Re: cron not working on fresh installation (Moodle 3.7)

by Ken Task -
Picture of Particularly helpful Moodlers

Apache id 200 means ok, but see the bytes are all the same (63) and every 5 minutes (recommended is every minute) + the 'cron service' appears to be web based.   All the scripts in admin/cli/  are restricted to command line (cli).

Server appears to Linux of some flavor so the setup of cron for moodle should be using servers native crontab.

Please see: https://docs.moodle.org/37/en/Cron

'SoS', Ken

In reply to Ken Task

Re: cron not working on fresh installation (Moodle 3.7)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm sure it's what you meant... but the 200 means the 'GET' worked ok. There's no implication that it hasn't returned a bunch of error messages. Which, of course, will be what it has done.

Is it as simple as web-based cron has not been switched on? It's off by default.

As others have noted, if there's some way you can run the command line cron it would be better. Moodle has been threatening to remove the web-based version for years.
In reply to Howard Miller

Re: cron not working on fresh installation (Moodle 3.7)

by Ken Task -
Picture of Particularly helpful Moodlers

Yep, you are correct Howard!  200 indicates wget worked but doesn't mean actually running all of cron/task ... just like a mysqldump.

Still seems to be some conflicting info?

Moodle 3.7 ...
admin/cron.php file has the follwoing in comments:

 * This file is best run from cron on the host system (ie outside PHP).
 * It is strongly recommended to add password protection via admin settings.
 *
 * eg   wget -q -O /dev/null 'http: *moodle.somewhere.edu/admin/cron.php?password=SeCreT666'
 *
 * It is also possible to use CLI script admin/cli/cron.php instead,
 * you can not call this script from command line any more.

In a posting about cron a couple of years ago, a Moodle core programmer
said such methods (wget) have been depreciated and one should use the cron script in admin/cli/

In moodle docs online,
https://docs.moodle.org/37/en/Cron
there is a link for cron services.

"EasyCron - A webcron service provider that eliminates the need of crontab or other task schedulers to set cron job."
Screen shot uses wget as above example.

On remotely hosted systems using Easy Apache, cron has to be setup finding php-cli ...
and not the php used for the web service.

In moodle code directory, 'which php' on some systems using Easy Apache errantly found the highest available php version first ... has to do with how many versions of php provider has via cPanel/Easy Apache and the environmental path of system .

Have been into at least 6 different provider VPS's and it hasn't always been the same!!!
 
That to say ... no way Moodle docs could be 100% correct and cover all providers! :|

Always an 'adventure'!

'SoS', Ken

In reply to Ken Task

Re: cron not working on fresh installation (Moodle 3.7)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yes, that! Every so often there's a threat to remove the non-cli version of cron. Hasn't happened.