Cron and Moodle 2.1

Cron and Moodle 2.1

by Larry Johnson -
Number of replies: 8

using Moodle 2.1.2+ (Build: 20111102)

hostgator.com is my hosting company

http://www.crcec.us/moodle/admin/cli/phpinfo.php

is my moodle phpinfo file.  Notice it is 5.3+

When i setup cron with this command.

php /home/crcpar/public_html/moodle/admin/cli/cron.php

i get this email error from cron.

Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version 5.2.17).
Some servers may have multiple PHP versions installed, are you using the correct executable?

I had 3 or 4 techs check it out but to no avail

A little history.  Hostgator by default installs 5.2 on all there sites, but I had them update it to 5.3 before I installed Moodle.  And moodle installed with no errors and everything is green.

What are my options?  Thanks,

 

Average of ratings: -
In reply to Larry Johnson

Re: Cron and Moodle 2.1

by Robert Chalmers -

I had a hosting company that had multiple PHP installs. All but the base one 4.x were CGI versions. These aren't the full install as far as I can tell, and if your hosting has an option you will always default to the base binary.

I had an option however, where I could select the one I wanted, and only theone I wanted from the admin interface. It kind of worked.

In the end - I've run my own server and got over the problem entirely. Hosting sites are good for the 'masses' but notgood for something out of the ordinary mainstream of services like Moodle.

In reply to Robert Chalmers

Re: Cron and Moodle 2.1

by Larry Johnson -

Im sure they might have something not 100% pure php 5.3, but why does the moodle install with no signs of php 5.2 and the cron.php in moodle detect 5.2?

 

/home/crcpar/public_html/moodle/admin/cli/cron.php

 

phpinfo.php shows 5.3

In reply to Larry Johnson

Re: Cron and Moodle 2.1

by Ken Task -
Picture of Particularly helpful Moodlers

Since hosting provider has multiple installs of php and you have command line access, you need to find out if your command line environment is 'finding' the newer version of php required.

Try: which php (note the path).

To find which php is being called when issuing a command for cron. 

Also try php -v for the version.  If the version is not the one needed, you might need to inquire with hosting provider as to your command line environment and the 'path' to the newer version of php.

Also clue might be in the phpinfo, at the top, it shows how php was compiled:

'--with-exec-dir=/usr/bin'

Is the line I see on a server with a single version of php.

You might have to use /usr/bin/php53 when issuing commands - depending upon how the hosting provider has installed/setup, etc.

'spirit of sharing', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Cron and Moodle 2.1

by Larry Johnson -

Thanks Ken you are correct.

Now it works perfect.  Here is the correct path and command in case someone else from HostGator.com needs it.

When you run a PHP script under cron with:
php /home/crcpar/public_html/moodle/admin/cli/cron.php

This runs the server default PHP version, which is 5.2.17


In order to run a PHP script under cron in PHP version 5.3 you must point the cron job to the 5.3 PHP binary:
/opt/php53/bin/php /home/crcpar/public_html/moodle/admin/cli/cron.php

Average of ratings: Useful (2)
In reply to Larry Johnson

Re: Cron and Moodle 2.1

by Sheila Stamp -

Thanks for this info - it helped me talk to my own host provider and get the code I needed.

For anyone using Arvixe this is PHP script you need:

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

In reply to Sheila Stamp

Re: Cron and Moodle 2.1

by Bernd Albers -

Could you explain why you use the "admin/cli/cron.php" instead of the "admin/cron.php" where it says:
 
 * This script looks through all the module directories for cron.php files
 * and runs them.  These files can contain cleanup functions, email functions
 * or anything that needs to be run on a regular basis.
 *
 * This file is best run from cron on the host system (ie outside PHP).
 * It is strongly recommended to add password protection via admin settings.
 *
 * eg   wget -q -O /dev/null 'http: *moodle.somewhere.edu/admin/cron.php?password=SeCreT666'
 *
 * It is also possible to use CLI script admin/cli/cron.php instead,
 * you can not call this script from command line any more.
 *
 * @package    core
 * @subpackage admin
 * @copyright  1999 onwards Martin Dougiamas  http://dougiamas.com
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

Is there any advantage to that one?

Kind regards Bernd

In reply to Bernd Albers

Re: Cron and Moodle 2.1

by Bret Miller -
Picture of Particularly helpful Moodlers

The difference is in how you run cron. The "cli" version is designed to run as a command-line application and is ideally suited for unix cron while the other version is designed to run as a web page. I'm not versed in the code well enough to know whether "wget http://your-site/admin/cron.php" is equivalent to "php /path-to-site/admin/cli/cron.php". I'd suspect they operate similarly other than one is designed to be run by apache and the other by command line.

In reply to Bret Miller

Re: Cron and Moodle 2.1

by Anne Krijger -

And you are right on the money.

They both do some checking and then call cron_run() in /lib.cronlib.php

Anne.