is cron job necessary?

is cron job necessary?

by Chuck Guilford -
Number of replies: 9

i don't understand what a cron job does. if it's just for sending out email and i don't want to send out email through my site do i need to bother with it?

my hosts don't give every 15 minutes as an option. once a day is the best they offer.

Average of ratings: -
In reply to Chuck Guilford

Re: is cron job necessary?

by Tony Hursh -
There are various other tasks handled by the cron job (e.g., running backups and updating the status of activities). Probably better to run it, even if you're not sending out email. smile


In reply to Tony Hursh

Re: is cron job necessary?

by Chuck Guilford -

thanks for the quick response.

2 more questions:

  1. will once a day be adequate, or should i try to get it done more often?
  2. is there any reason i would want to have them mail me the results?

In reply to Chuck Guilford

Re: is cron job necessary?

by Tony Hursh -
If you have another computer with a full time Internet connection, you can set up a cron job on that computer to run the cron job on your server as often as you want. smile

Basically, all you really need to do to run the Moodle cron is to retrieve the URL:

http://yourmoodlesite.com/admin/cron.php

You can even do it with a browser, but it's better to do it in an automated way. If you run Windows, you can use the Windows cron package for Moodle to do this. If you run Linux or OS X, you can set up your local cron to do it.

See the manual section on cron for more information.

I'm not an expert on the cron functions, but I'd guess that once a day isn't really often enough. Maybe someone else will weigh in on this.

In reply to Tony Hursh

Re: is cron job necessary?

by Laurie Savage -
The documentation suggests every five minutes for a working site.

The header of the file 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).
/// The script can either be invoked via the web server or via a standalone
/// version of PHP compiled for CGI.
///
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
/// or php /web/moodle/admin/cron.php


If you are running Linux can I suggest man crontab and man 5 crontab as sources of good information on this very powerful utility.

Cheers
In reply to Chuck Guilford

Re: is cron job necessary?

by Mark Stevens -
Hi,

The cron job does lots of things, and I think Martin compared it to the heartbeat of your Moodle site.  For most people sending postings from forums is the most important.  So, if you want forum postings to be sent regularly, have a cron run very frequently (every 5 minutes).  [Forum postings are only sent after the maxediting time:  30 minute default.]  If you think your server is getting slowed by frequent cron jobs, make it less frequent (every 15 minutes or even your once a day smile  but that seems like it defeats the purpose of a dynamic web site if you are only "updating" it once a day.

Sometimes cron jobs take 0.15 seconds, and if a backup is involved of a large site on a slow machine, it could take several minutes.

M
In reply to Chuck Guilford

Re: is cron job necessary?

by Timothy Takemoto -

If your host does not do frequent crons, and you don't have a windows/linux computer running somewhere else that will ping your cron for you, then in many cases I think that a once-a-day cron will be okay.

1) Timed automtatic backups (once a day should be okay. I backup only once a day anyway. )
2) Notification of Forum posts (since you don't want to send out email this you do not need to do at all)
Updating the status of Assignments, Journals and Workshops. I am not 100% sure of what that means, but I think that it may include changing the link from something like "post your assignment" (journal, to this workshop) to "this assignment is now closed." Not everyone is using these modules. If you are not using these modules then you do not need to worry. If you are, then even so, if you cron fires off at 8 in the morning or something, the all it will will mean, I think, is that that the status (open closed, ready to mark other peoples etc) will change only once a day. And for many purposes this should be sufficient.

BUT if your ISP does not provide a frequen cron, you do not have another computer running, then you might still use a cron service at another ISP. Some of these are free. Please see this post for suggestions of some rented and free chron services.


Tim

tkmk
 

In reply to Timothy Takemoto

Re: is cron job necessary?

by Timothy Takemoto -

Come to think of it, many the blocks (displayed in the left and right hand columns). But here again, I am not sure that it would be that much of an inconvenience to have the cron fire once a dad.

If you did not have a more frequent cron then you would not be able to display "online users," meaningfully.

But the other blocks that depend upon events, such as "recent activity", the calendar, "recent news", might be updated only once a day without all that much inconvenience.

Tim

In reply to Timothy Takemoto

What the cron job does

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
None of that stuff you mentioned in the blocks is generated by cron - all of that is created on the fly for each user. Lot of other things ARE done by cron, though.

These are done every time you run cron:
  • email postings from Forums, Assignments and Journals
  • generating new RSS feeds from Forums and Glossaries
  • processing external enrolments (eg flatfile enrolments plugin)
  • running extra arbitrary admin jobs from dataroot/cronextra.php

These are done 20% of the time (on average):
  • unenrolling users who haven't been around for a long time
  • deleting old logs to save space
  • deleting old cached texts to keep performance up
  • notify admins of login failures

These are done according to various schedules
  • creating automatic backups of all courses
  • gathering RSS feeds (for the RSS client block in 1.5)

Once a day is not enough for anything but a test site. Once an hour would not be ideal but would be usable. My servers run cron.php every 10 minutes which I think is a pretty optimum figure.
In reply to Martin Dougiamas

Re: What the cron job does

by Timothy Takemoto -

Martin, Chuck

Sorry about that. It was the "cron" field in the "moodle_blocks" database table that confused me. I see now that the value in the cells of that field are all zero - probably meaning they don't use the cron blush.

Sorry to disagree with the Master Moodler but, six months ago, in my foolishness, I ran a Moodle installation for about 6 weeks for two or three classes, without any cron at all. It functioned satisfactorily, as a place to distribute materials, for forums (without email notification of course, and suddenly a deluge at the end), and quizes (I think).  The chron was there at the beginning of term for the student to enrol (confirmation emails) but part way through I changed servers or something and forgot to set up a chron again. Part the way through the term I realised that I was having to manually confirm the course enrollment of latecoming students (Art explains how here) who were not getting enrollment confirmation mails and eventually twigged.

Of course one gets nothing like the full functionality, I wasn't (don't) use most on the functions that Martin mentions, so if you  don't have a cron and cannot afford one (or don't want to change ISP), it might be worth a try. 

But perhaps cron-essential-functionality was brought in since July last year.

Tim
tkmt