Difference between revisions of "Talk:Cron"

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 3.1. Up-to-date documentation for the latest stable version of Moodle is probably available here: Cron.

m
(Will create change on this page later: Chris starting draft of new Cron page here)
Line 16: Line 16:
 
Not hearing any immediate response to my proposals, I will wait a few days before I change things--[[User:chris collman|chris collman]] 22:58, 17 November 2011 (WST)
 
Not hearing any immediate response to my proposals, I will wait a few days before I change things--[[User:chris collman|chris collman]] 22:58, 17 November 2011 (WST)
  
I will create a template at that time, put in sublinks to the new pages at the top of this page.  I will reformat this page and deal with all the processes that cron deals with :) --[[User:chris collman|chris collman]] 22:58, 17 November 2011 (WST)
+
Seems excessive to create a Cron settings page but why not, that is consistent with other functions --[[User:chris collman|chris collman]] 22:02, 19 November 2011 (WST)
 +
 
 +
::'''DRAFT OF NEW CRON PAGE STARTS HERE''' (will remove later)
 +
Cron is the name of a Unix program that runs predefined tasks on a computer at regular intervals. It assists some of Moodle's modules to perform tasks on a scheduled basis. For example, the cron process might tell Moodle to check all discussion forums so it can mail out copies of new posts to people who have subscribed to that forum.
 +
 
 +
The primary Moodle script that does all this is located in the admin directory, and is called cron.php. However, it can not tell itself to run, so you need to set up a mechanism where this script is run regularly (eg every five or ten minutes). This provides a "heartbeat" so that the script can perform functions at periods defined by each module. This kind of regular mechanism is known as a cron service. The service can be part of a webhost or can be something run from a different server or computer.
 +
 
 +
==Starting cron==
 +
There are a number of way to invoke cron.php. Cron can be started from the address bar in a browser (URL usually ending in admin/cron.php), via a [[Daemon]], or wq1et, curl or some other code.
 +
 
 +
===Cron service location and timing===
 +
Note that the machine performing the cron '''does not need to be the same machine that is running Moodle'''. For example, if you have a limited web hosting service that does not have a cron service, then you might choose to run cron on another server or on your home computer. All that matters is that the cron.php file is called regularly.
 +
 
 +
The load of this script is not very high, so 5 minutes is usually reasonable, but if you're worried about it you can reduce the time period to something like 15 minutes or even 30 minutes. It's best not to make the time period too long, as delaying mail-outs can slow down activity within the course. Remember that mail-outs also wait for the editing time to expire before being queued for sending.
 +
 
 +
===Testing cron and manual trigger===
 +
First, test that the script works by running it directly from your browser: ''<nowiki>http://example.com/moodle/admin/cron.php</nowiki>''
 +
 
 +
If cron is called from the command line by any user logged in to your Moodle it will create a temporary admin environment in order to run and then log the user out. You can disable command line running of cron by disabling the appropriate section in the cron.php file.
 +
 
 +
Next, you need to set up a way to manage an automatic scheduled process to run the script on a regular basis. This will depend upon the operating system and program you select.
 +
 
 +
 
 +
::'''END OF DRAFT PAGE HERE'''

Revision as of 14:02, 19 November 2011

Comment from Eloy:

"If there is some template to mark one page as "require some love" I'd say https://docs.moodle.org/en/Cron requires it. It talks 99% of the time to use web-browser cron. Only 1 line talks about cli cron." --Helen Foster 20:44, 9 November 2011 (WST)

I just noticed this comment. Cron is not one of my special areas of knowledge but obviously use it. Did a quick "Cron CLI" on the web and got lost in how to program a php file to run cron jobs. Saw the note about 2.0 and CLI on this page.

I think Eloy's comment is also saying that this page is too long and could be split up? For example use a navtrail and a Cron template. Proposed pages:

Comments? --chris collman 23:25, 12 November 2011 (WST)

Will create change on this page later

Not hearing any immediate response to my proposals, I will wait a few days before I change things--chris collman 22:58, 17 November 2011 (WST)

Seems excessive to create a Cron settings page but why not, that is consistent with other functions --chris collman 22:02, 19 November 2011 (WST)

DRAFT OF NEW CRON PAGE STARTS HERE (will remove later)

Cron is the name of a Unix program that runs predefined tasks on a computer at regular intervals. It assists some of Moodle's modules to perform tasks on a scheduled basis. For example, the cron process might tell Moodle to check all discussion forums so it can mail out copies of new posts to people who have subscribed to that forum.

The primary Moodle script that does all this is located in the admin directory, and is called cron.php. However, it can not tell itself to run, so you need to set up a mechanism where this script is run regularly (eg every five or ten minutes). This provides a "heartbeat" so that the script can perform functions at periods defined by each module. This kind of regular mechanism is known as a cron service. The service can be part of a webhost or can be something run from a different server or computer.

Starting cron

There are a number of way to invoke cron.php. Cron can be started from the address bar in a browser (URL usually ending in admin/cron.php), via a Daemon, or wq1et, curl or some other code.

Cron service location and timing

Note that the machine performing the cron does not need to be the same machine that is running Moodle. For example, if you have a limited web hosting service that does not have a cron service, then you might choose to run cron on another server or on your home computer. All that matters is that the cron.php file is called regularly.

The load of this script is not very high, so 5 minutes is usually reasonable, but if you're worried about it you can reduce the time period to something like 15 minutes or even 30 minutes. It's best not to make the time period too long, as delaying mail-outs can slow down activity within the course. Remember that mail-outs also wait for the editing time to expire before being queued for sending.

Testing cron and manual trigger

First, test that the script works by running it directly from your browser: http://example.com/moodle/admin/cron.php

If cron is called from the command line by any user logged in to your Moodle it will create a temporary admin environment in order to run and then log the user out. You can disable command line running of cron by disabling the appropriate section in the cron.php file.

Next, you need to set up a way to manage an automatic scheduled process to run the script on a regular basis. This will depend upon the operating system and program you select.


END OF DRAFT PAGE HERE