|
static | prepare_core_renderer ($restore=false) |
| Prepare the output renderer for the cron run.
|
|
static | reset_user_cache () |
| Resets the cache for the cron user used by setup_user() .
|
|
static | run_adhoc_task (int $taskid) |
| Execute an adhoc task.
|
|
static | run_adhoc_tasks (int $startruntime, $keepalive=0, $checklimits=true, ?int $startprocesstime=null, ?int $maxtasks=null, ?string $classname=null,) |
| Execute all queued adhoc tasks, applying necessary concurrency limits and time limits.
|
|
static | run_failed_adhoc_tasks (?string $classname=null) |
| Execute all failed adhoc tasks.
|
|
static | run_inner_adhoc_task (\core\task\adhoc_task $task) |
| Shared code that handles running of a single adhoc task within the cron.
|
|
static | run_inner_scheduled_task (\core\task\task_base $task) |
| Shared code that handles running of a single scheduled task within the cron.
|
|
static | run_main_process (?int $keepalive=null) |
| Execute cron tasks.
|
|
static | run_scheduled_tasks (int $startruntime, ?int $startprocesstime=null,) |
| Execute all queued scheduled tasks, applying necessary concurrency limits and time limits.
|
|
static | set_process_title (string $title) |
| Sets the process title.
|
|
static | setup_user (?stdClass $user=null, ?stdClass $course=null, bool $leavepagealone=false) |
| Sets up a user and course environment in cron.
|
|
static | trace_time_and_memory () |
| Output some standard information during cron runs.
|
|
|
static stdClass stdClass | $cronsession = null |
| The cron user's session data.
|
|
static stdClass stdClass | $cronuser = null |
| A copy of the standard cron 'user'.
|
|
◆ prepare_core_renderer()
static core\cron::prepare_core_renderer |
( |
| $restore = false | ) |
|
|
static |
Prepare the output renderer for the cron run.
This involves creating a new $PAGE, and $OUTPUT fresh for each task and prevents any one task from influencing any other.
- Parameters
-
bool | $restore | Whether to restore the original PAGE and OUTPUT |
◆ run_adhoc_task()
static core\cron::run_adhoc_task |
( |
int | $taskid | ) |
|
|
static |
Execute an adhoc task.
- Parameters
-
◆ run_adhoc_tasks()
static core\cron::run_adhoc_tasks |
( |
int | $startruntime, |
|
|
| $keepalive = 0, |
|
|
| $checklimits = true, |
|
|
?int | $startprocesstime = null, |
|
|
?int | $maxtasks = null, |
|
|
?string | $classname = null ) |
|
static |
Execute all queued adhoc tasks, applying necessary concurrency limits and time limits.
- Parameters
-
int | $startruntime | The time this run started. |
int | $keepalive | Keep this public static function alive for N seconds and poll for new adhoc tasks. |
bool | $checklimits | Should we check limits? |
null | int | $startprocesstime | The time this process started. |
int | null | $maxtasks | Limit number of tasks to run` |
null | string | $classname | Run only tasks of this class |
- Exceptions
-
◆ run_failed_adhoc_tasks()
static core\cron::run_failed_adhoc_tasks |
( |
?string | $classname = null | ) |
|
|
static |
Execute all failed adhoc tasks.
- Parameters
-
string | null | $classname | Run only tasks of this class |
◆ run_inner_adhoc_task()
Shared code that handles running of a single adhoc task within the cron.
- Parameters
-
◆ run_inner_scheduled_task()
Shared code that handles running of a single scheduled task within the cron.
Not intended for calling directly outside of this library!
- Parameters
-
◆ run_main_process()
static core\cron::run_main_process |
( |
?int | $keepalive = null | ) |
|
|
static |
Execute cron tasks.
- Parameters
-
int | null | $keepalive | The keepalive time for this cron run. |
◆ run_scheduled_tasks()
static core\cron::run_scheduled_tasks |
( |
int | $startruntime, |
|
|
?int | $startprocesstime = null ) |
|
static |
Execute all queued scheduled tasks, applying necessary concurrency limits and time limits.
- Parameters
-
int | $startruntime | The time this run started. |
null | int | $startprocesstime | The time the process that owns this runner started. |
- Exceptions
-
◆ set_process_title()
static core\cron::set_process_title |
( |
string | $title | ) |
|
|
static |
Sets the process title.
This makes it very easy for a sysadmin to immediately see what task a cron process is running at any given moment.
- Parameters
-
string | $title | process status title |
◆ setup_user()
static core\cron::setup_user |
( |
?stdClass | $user = null, |
|
|
?stdClass | $course = null, |
|
|
bool | $leavepagealone = false ) |
|
static |
Sets up a user and course environment in cron.
Note: This function is intended only for use in:
- the cron runner scripts
- individual tasks which extend the adhoc_task and scheduled_task classes
- unit tests related to tasks
- other parts of the cron/task system
Please note that this function stores cache data statically.
- See also
- reset_user_cache() to reset this cache.
- Parameters
-
null | stdClass | $user | full user object, null means default cron user (admin) |
null | stdClass | $course | full course record, null means $SITE |
null | bool | $leavepagealone | If specified, stops it messing with global page object |
◆ trace_time_and_memory()
static core\cron::trace_time_and_memory |
( |
| ) |
|
|
static |
Output some standard information during cron runs.
Specifically current time and memory usage. This method also does gc_collect_cycles() (before displaying memory usage) to try to help PHP manage memory better.
◆ DEFAULT_MAIN_PROCESS_KEEPALIVE
int const core\cron::DEFAULT_MAIN_PROCESS_KEEPALIVE = 3 * MINSECS |
Use a default value of 3 minutes.
The recommended cron frequency is every minute, and the default adhoc concurrency is 3. A default value of 3 minutes allows all adhoc tasks to be run concurrently at their default value.
The default keepalive value for the main cron runner
The documentation for this class was generated from the following file: