cron.php maintenance script

cron.php maintenance script

by Steve Hill -
Number of replies: 15

Hi,
I was wondering what was the easiest way of running the cron.php maintenance script on a regular basis? The site is hosted by a hosting company. At present I just click the link in the
Notifications area of the admin area.

Cheers,
Steve

Average of ratings: -
In reply to Steve Hill

Re: cron.php maintenance script

by Nathaniel Catchpole -

If you're on a Cpanel host, you should be able to set up a cron job via the admin interface. If you have shell access, you can use crontab -e

Can you provide more information about your hosting setup?

In reply to Nathaniel Catchpole

Re: cron.php maintenance script

by Steve Hill -

Does anyone know if you can run cron.php from CMD in windows and set it as a Scheduled Task? If so, can you let me know what I have to do?

Steve

In reply to Steve Hill

Re: cron.php maintenance script

by John Mc Hale -

create a command script (*.cmd) file; e.g. runcron.cmd

In this file, you put the command to run the cron script via php; e.g.

c:\php\php.exe -f c:\moodle\admin\cron.php

(If you have included the PHP folder in your system's path variable, then you only need:

php -f c:\moodle\admin\cron.php

)

Now create a scheduled task and Browse for the command file you just created and set up your scheduled task as required. I recommend that you create a separate account on your computer (not Admin) for running the script. You will need to provide a username/password to run the scheduled task.

Hope this helps

In reply to John Mc Hale

Re: cron.php maintenance script

by Steve Hill -

Thanks for the infomation.

That is OK if you have Moodle running on your own machine but I have it hosted and wondered if you could run the Cron.php with a script?

In reply to Steve Hill

Re: cron.php maintenance script

by Ken Wilson -

Hi Steve

Moodle's cron script can be executed remotely, so you can use John's instructions on your own PC if you have PHP installed. If not, you could try using wget - there is a version available for windows. See the Windows instructions in the Cron docs (http://docs.moodle.org/en/Cron#On_Windows_systems).

Ken

In reply to John Mc Hale

Re: cron.php maintenance script

by Jaime Esteban -
Hello,

I have had a repeated, and still not solved, problem with the nigthly scheduled backup. There are a couple of courses that cannot be backuped although I can back them up manually.

It is not a problem of file size, neither a problem of execution time (at least I think so).

I have read on "Backup and Restore" forum about similar problems, but I have not found a definitive solution.

What I was now trying to do is to use a client php parser (CLI PHP), instead of "lynx", to run the "cron.php" script, as proposed in the Moodle documentation.

I have installed the "php4-cli" package from Debian and, when I try and use it, it does not work. When using it manually I always obtain the same error:

Fatal error: Call to undefined function: init_performance_info() in /var/www/moodle/lib/setup.php on line 93

Any suggestion?

Thanks in advance.

[Moodle 1.5.3+ on Debian sarge3]

In reply to Jaime Esteban

Re: cron.php maintenance script

by John Isner -
Ken Wilson suggested using wget. Did you? It worked for me when php5 did not. Try this:

*/5 * * * * wget -q -O /dev/null http://yourmoodlesite/moodle/admin/cron.php
In reply to John Isner

Re: cron.php maintenance script

by Jaime Esteban -
I have tried with "wget", but the result is the same than with "lynx", that is, the scheduled backup is unable to finish a couple of courses amongst fourteen.

I have read about the highest efficiency of using a php client. That was the reason I tried to use it.

Thanks anyway.
In reply to Jaime Esteban

Re: cron.php maintenance script

by Mauno Korpelainen -

Hi Jaime,

the reason for backup failure is usually some non standard block or module (for example dfwiki, feedback) or one fault sign in database.

In reply to Mauno Korpelainen

Re: cron.php maintenance script

by Jaime Esteban -
Hello Mauno,

I am not using any non-standard block, so it could be what you call "one fault sign in database". But, what do you refer to with "fault sign"? Could you please explain it to me?

Sorry for my ignorance, and thanks a lot for your suggestions,

Jaime
In reply to Jaime Esteban

Re: cron.php maintenance script

by Mauno Korpelainen -

When I used moodle 1.5 I had sometimes problems with Dialogue module because it did not save ' as \' or some other sign if somebody wrote John's or John´s or John`s

Database finds this sign to be end of that field and causes error. With moodle 1.6 and 1.7 I have no more had problems with these signs but some blocks and modules using different coding than UTF8 may cause some problems too.

In reply to Mauno Korpelainen

Re: cron.php maintenance script

by Jaime Esteban -
Now I know what you meant.

My site is used by spanish speakers, so it is not likely that they have used these signs, but I will do an extensive search anyway.

Thanks again,

Jaime