Moodle cron job failing

Avatar
  • Answered
I have been unable to get my daily cron job for a Moodle installation working. I need to call this script each night:
https://www.ligminchalearning.com/crs2/admin/cron.php

Here's the support article from Moodle on how to configure the cron:
http://docs.moodle.org/25/en/Cron_with_Unix_or_Linux

I found the recommended wget method is blocked on your system, so I have tried curl, but it hasn't run properly yet. I have tried this a few different ways, and just set it to:
/usr/bin/curl https://www.ligminchalearning.com/crs2/admin/cron.php -o /dev/null/ -silent

Should the above work, or do you have a different approach you would suggest?

Thanks!
John Jackson
Avatar
JacobIMH
Hello John, and thank you for your question. We have a guide about how to run a cron job that mentions wget is disabled on all our shared servers, you could instead use the curl command, but need to be sure to define a User-Agent so that it is not blocked by ModSecurity rules on the server. In your case, the final command would need to look something like:
/usr/bin/curl --user-agent cPanel-Cron https://www.ligminchalearning.com/crs2/admin/cron.php -o /dev/null/ -silent
Now if you take a look in your website's access-logs, instead of just saying curl/7.15.5 as the User-Agent, it would instead read cPanel-Cron. You can have it say whatever you'd like, just so long as it is defined. Let us know if you had any other questions at all. - Jacob