The problem
I'm running a new install of Moodle 2.2 and noticed my cron.php was still not working, despite adding the necessary lines to my crontab file. I am now using putty.exe to try to invoke my cron.php on my 1and1.co.uk shared Linux server and am getting the following messages:
I solved the first error by going into my cron.php and commenting out line 56 under the line that says // extra safety. Presumably in doing so I became less safe somehow. This removes the error but then I get a second error (shown above). I do not want to keep going into Moodle files to comment out stuff add infinitum until my cron runs, since I do not know what I am doing. Does anyone have any clues as to what to do here to get my cron to run automatically?
The offending line in setup.php is line 658 and, starting from line 657, it goes as follows
// Defining the site - aka frontpage course
try {
$SITE = get_site();
} catch (dml_exception $e) {
$SITE = null;
if (empty($CFG->version)) {
$SITE = new stdClass();
$SITE->id = 1;
} else {
throw $e;
}
}
What I have done so far:
I have run cron.php from a browser and it runs properly without any error messages at all or undue delays, taking just over one second to run.
I have created a cronTest.php file as suggested in the 1and1 tutorial here http://faq.1and1.com/scripting_languages_supported/cron_jobs/3.html This works fine as described in the tutorial. I have also added a line to my crontab using PuTTY that invokes this cronTest.php file every 15 mins as desired and it works and I receive the emails on the dot every 15 minutes.
So I know that cron is able to run properly on my server and that I can invoke the necessary files by adding lines to my crontab file. The cron.php file is clearly running, and somehow generating these errors. What is causing the errors and how can I proceed?
PS I added a "cli/" into the above path to my cron.php and the same error results