Hi all !
On our Moodle site (10.2) we have trouble recieving emails from forum posts.
I started looking at cron jobs, and see that there are two cron.php documents
One in public_html and on in the cli folder.
Should both these cron jobs be running on the site ?
Hi all !
Only one is needed ... the cron.php script in code/admin/ can be run from web (with password setup). The cron.php script in code/admin/cli/ is the one that should be set up in your operating system cron jobs.
The issue with email from forum post might have addition things to check ... smtp relay might have a throttle setting such that a forum that has a bunch of users (like in 100's or 1000's) won't accept but X messages in one days distribution of postings in forum.
See your sites adhoc task to see if there are forums postings in the que to be sent. adhoc task are like a backlog que of stuff executed normally by cron job that, for some reason, couldn't be completed.
Also, check servers error logs as well as mail logs for clues/hints.
Some hosting setups (depending upon lease and setup) write an error_log file in code directory where the error occurs. Might use cPanel or other panel's file browsing to see if you can find some of those.
Thanks for the info, Ken
This site has over 20 000 students logging on.
The analytics were taking and incredibly long time so I disabled them
Since then, the cron job still takes more than a minute.
Execution took 95.93437 secondsIs this normal ?
Not sure anyone could say what's normal for a site ... cron job/task and what data those work with dependent upon site - number of students in system, number of students *active* in any course, number of persons logging on at one time or in a small time frame (like a minute), etc.
95.9 seconds is longer than desired - that's like 2 minutes - but that - might be restricted by hosting also ... so it's the best you can do given setup/hosting, etc.
So ... as long as cron completes successfully ... and there aren't many adhoc task in the que to execute later, the only advice I could give is check if cron completed successfully frequently.
Logging on and going to Server Notifications will tell you if cron hasn't run within 240 seconds or not. That's one way of checking.
The other is to change the cron job redirect which in docs
shows as >/dev/null ... instead have it log to a file that is overwritten each time it runs. > /var/log/moodle-cron.log
The moodle-cron.log file has to be created manually ... moodle can't create it and neither can the cron job. And it has to be writeable by the user under wihich the cron job is running. How you are hosted may not allow you to do that.
Once one gets that worked on, one can actually watch the cron job via ssh and a 'tail' command ... thusly: tail -f /var/log/moodle-cron.log
As cron executes, the tail command above will show activity.
I can activate the cron job in my browser, with a password.
To check if the cron job was working on its own on the site, I asked to be emailed when it is completed.
This is the message I get regularly
"Command line scripts must define CLI_SCRIPT before requiring config.php"
Can you explain to me what that means ?
Thanks in advance
There exist 2 cron.php scripts in moodle code. The one you can use with password via web browser is in moodlecode/admin/cron.php.
https://site/admin/cron.php - you will be required to login and account used to login must be an admin level account.
The other cron.php script, the one that should be set up in your operating system cron jobs, is in moodlecode/admin/cli/cron.php ... cli directories in moodle are php scripts that require being run from the command line of the server only. Those scripts have a 'require' line in it's code that uses a php/moodle library for command line php.
I'm still recieving the message
Command line scripts must define CLI_SCRIPT before requiring config.php
and I don't know how to fix that. Where can the CLI_SCRIPT be defined ?
More info ... version of Moodle for one.
Does site have any customized script that's attempting to use CLI?
Example: cron.php in code/admin/cli/ has this in top of the script:
require_once($CFG->libdir.'/clilib.php'); // cli only functions
Has your moodlecode/admin/cli/cron.php file been modified?
Turn on debugging. Let's see what Moodle might be complaining about that we don't know about. We need to find out what php script is being called that (according to what has been shared so far) requires reading config.php ... that file is read all the time ... by almost every click a user might make.