MDL-67211 Tasks: Add cron_enabled setting.

Co-authored-by: Sam Marshall <s.marshall@open.ac.uk>
This commit is contained in:
Mikhail Golenkov 2020-08-25 16:49:20 +10:00
parent 45875f6f7b
commit d7342dc239
12 changed files with 193 additions and 9 deletions

View file

@ -30,8 +30,17 @@ require_once("$CFG->libdir/clilib.php");
require_once("$CFG->libdir/cronlib.php");
list($options, $unrecognized) = cli_get_params(
array('help' => false, 'list' => false, 'execute' => false, 'showsql' => false, 'showdebugging' => false),
array('h' => 'help')
[
'help' => false,
'list' => false,
'execute' => false,
'showsql' => false,
'showdebugging' => false,
'force' => false,
], [
'h' => 'help',
'f' => 'force',
]
);
if ($unrecognized) {
@ -49,6 +58,7 @@ if ($options['help'] or (!$options['list'] and !$options['execute'])) {
--showsql Show sql queries before they are executed
--showdebugging Show developer level debugging information
-h, --help Print out this help
-f, --force Execute task even if cron is disabled
Example:
\$sudo -u www-data /usr/bin/php admin/cli/scheduled_task.php --execute=\\core\\task\\session_cleanup_task
@ -121,6 +131,11 @@ if ($execute = $options['execute']) {
exit(1);
}
if (!get_config('core', 'cron_enabled') && !$options['force']) {
mtrace('Cron is disabled. Use --force to override.');
exit(1);
}
\core\task\manager::scheduled_task_starting($task);
// Increase memory limit.