Cron job error

Cron job error

Dominick Inglese གིས-
Number of replies: 3

Hello everyone, 

I really tried to look around before posting ~ but I am still having an error so here goes:

I am using moodle 2.2 on a cPanel with PHP 5.3 

I followed instructions here http://docs.moodle.org/20/en/Cron_with_web_hosting_services:

By the way the site I am developing is:  

http://supremeducation.com/studyonline/login/index.php 

I tested this cron job:

Command:

wget -q -O /dev/null http://supremeducation.com/studyonline/admin/cli/cron.php 

But I get this error in my email inbox:

Status: 404 Not Found
X-Powered-By: PHP/5.2.17
Content-type: text/html

No input file specified.

 

Then I tested this command: 

c:\studyonline\admin\cli\cron.php

and I am getting this error:

/bin/sh: c:/studyonline/admin/cli/cron.php: No such file or directory
 
 
(The reason I am trying to do this is because I got an error under "notifications" in the administrator block that says the cron has not run in over 24 hours. Then I click the "cron" link and apparently it ran successfully. So, I could just click that every once in a while but I am curious about how to set the cron properly.)
 
How can I set up cron job properly?
 

Sincerely, 

Dominick Inglese 

Attachment cPanel cron configuration.png
དཔྱ་སྙོམས་ཀྱི་སྐུགས་ཚུ།: -
In reply to Dominick Inglese

Re: Cron job error

Rosario Carcò གིས-

Only a quick shot out of my crontab on linux, runnig Moodle 1.9x:

*/5 * * * * root wget -q -O /var/log/moodleCron.log https://moodle.fhnw.ch/admin/cron.php

to use this you need to setup your cron to be callable/runnable by web. In my case I disabled cron by web so as not to use the overhead of my apache web server. Instead I call it directly on the command line now. Again my line out of crontab:

*/5 * * * * root /webserver/mysqlBackups/startMoodleCron.sh 2>&1 >/var/log/moodleStartCron.log

My shell script startMoodleCron.sh looks like this and I use it to better control the cron-job's output:

#!/bin/bash
#startMoodleCron.sh
#
#we call the moodle cron jobs with this script rather than directly
#in the crontab, to preserve every log and wget output file by
#renaming them. Logrotate will be able to compress and rotate
#them with the wildcards moodle*.log

DATE=`date +%Y%m%d-%H%M%S`
LOG_FILE=/var/log/moodleStartCron.$DATE.log

echo "startMoodleCron: starting, $LOG_FILE"

#prepare mail and mailmessage
MESSAGE="/tmp/startMoodleCron.txt"
echo "startMoodleCron: starting, $LOG_FILE" > $MESSAGE

#  wget --no-check-certificate -q -O $LOG_FILE https://moodle.test.fhnw.ch/admin/cron.php
#now we use php for better performance

php5 -f /webserver/webroot/htdocs/moodle/htdocs/admin/cron.php > $LOG_FILE

echo "startMoodleCron: finished `date +%Y%m%d-%H%M%S`"
echo "startMoodleCron: finished `date +%Y%m%d-%H%M%S`" >> $MESSAGE

#use mail only for debugging
#mail -s startMoodleCron -r moodle@fhnw.ch rosario.carco@fhnw.ch < $MESSAGE

exit 0

Rosario
In reply to Rosario Carcò

Re: Cron job error

Dominick Inglese གིས-

Hello Rosario,

Thanks for the reply. I contacted my host. And actually I think they have good service. They sent me a couple of emails and fixed the croncommand to look like this:

 

/usr/local/php53/bin/php -q /home/haribol/public_html/studyonline/admin/cli/cron.php

in this case "studyonline" is a directory where moodle is installed

This looks very different from your command. So, I was very confused. This command was not documented in the docs.moodle section.

 

So, does this mean the cron commmand varies acrose servers, hosts and other environmental factors?

 

 

In reply to Dominick Inglese

Re: Cron job error

Rosario Carcò གིས-

>>php5 -f /webserver/webroot/htdocs/moodle/htdocs/admin/cron.php > $LOG_FILE

is equivalent to what your provider proposes. The only difference is, that I write the output to a log-file I can review later in case of troubles. But as you do not have access to the serve's file system, they seem not to log your cron.php output. But you can see the Backup-Logs of Moodle in the table mdl_backup_log

Rosario