Fun with cron and cpanel!

Fun with cron and cpanel!

by David Kelly -
Number of replies: 8
Hi
running Cpanel 6 on Linux
Kernel version: 2.4.18-27.7.x
Apache version: 1.3.27 (Unix)
MySQL version: 4.0.12

I've tried all the options I can find for cron and still have had no joy with receiving forum notifications unless I manually trigger cron.php from a browser... doing it that way the mail arrives, so I presume the problem is with the cronjob config not the mail setup.

From Cpanel's info I've tried:
5 * * * * GET http://mydomain.com/path/admin/cron.php > /dev/null

and

*/5 * * * * GET http://mydomain.com/path/admin/cron.php > /dev/null

from the moodle install documentation I've tried:

*/5 * * * * wget -q -O /dev/null http://mydomain.com/path/admin/cron.php

and

5 * * * * wget -q -O /dev/null http://example.com/moodle/admin/cron.php


None of these have worked... does anyone have tried and tested Cpanel 6 cronjob syntax??

Regards
David
Average of ratings: -
In reply to David Kelly

Re: Fun with cron and cpanel!

by David Lamotte -
Hi,

Never used Cpanel 6 myself, but I just used the sample cron file supplied with Moodle.

In the admin directory, you will find a file "crontab.in"

This contains the default settings to run the cron function, every 5 minutes, using the command line version of php. You need to edit this file to check that the paths are all correct.

To install this file, change to the moodle/admin directory and issue the following commands

crontab -l >> crontab.in
crontab crontab.in

You do this from the command line, preferably as user "root". The first command lists and existsing cron settings, and adds them to the end of the moodle cron file, the second command then installs all the cron jobs.

This shuld get everything working, but get back to us if there are any errors or problems with this proceedure.

Good luck,
David
In reply to David Lamotte

Re: Fun with cron and cpanel!

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Actually there is no such crontab.in file included with Moodle, David L. mixed

David K, you might a need a full path for wget. eg /usr/bin/wget or something.
In reply to Martin Dougiamas

Re: Fun with cron and cpanel!

by David Lamotte -
Ooops,

Well MY moodle admin directory has one - but I can't remember where it came from.

Would it help to have a simple little script that locates where php is on your system, and uses this to created the desired crontab entry?

It would only take a few minutes for me to whip one up if desired.

David

In reply to David Lamotte

Re: Fun with cron and cpanel!

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
It would be cool if, when it couldn't find 'php' (because command-line php isn't that common) that it also looked for wget, lynx etc and basically advised on the best thing to do. smile Oh yes, and it would be extra nice if it checked crontab for an existing entry just in case it's been run twice.

(Gosh it's nice being on this side of the fence for a change! wink big grin )
In reply to David Kelly

Re: Fun with cron and cpanel!

by Ray Le Couteur -

This is the command I use in Cpanel 6:

15 * * * *   GET http://mydomain.com/admin/cron.php > /dev/null

Gives an hourly command.

Seems to work fine.

Ray

In reply to Ray Le Couteur

Re: Fun with cron and cpanel!

by David Kelly -
Interesting point that Ray

your command should give you 15 minute cronjobs

I finally got mine to work using WGET

5 * * * * wget http://mydomain.com/path/admin/cron.php > /dev/null

and I also get hourly cronjobs... I'm thinking that maybe the server host has the capability to limit the frequency of cronjobs for cpanel clients... if I find out any more I'll post again here

cheers for the help
David
In reply to David Kelly

Re: Fun with cron and cpanel!

by Héctor González Jaime -
to get 15 minute cronjobs, or 5 minute cronjobs you need to use:

*/15 * * * * wget ....
or
*/5 ....

if you use:

5 * * * * wget ...

you are telling cron to run at 0:05, 1:05, 2:05 ...
with */5 its 0:05, 0:10, 0:15 (every minute that is divisible by 5).
In reply to Héctor González Jaime

Re: Fun with cron and cpanel!

by David Kelly -
Gracias Héctor....

Its certainly been complicated getting my head round how cron works... cheers for the info