I am trying to schedule a task in moodle-cron-api following the instructions here at: https://docs.moodle.org/dev/Task_API.
I have the root folder at /local and the name of the root folder is mod_hygene.
I have a cut_my_toe_nails.php at /local/mod_hygene/classes/task which is:
namespace mod_hygene\task;
/**
* An example of a scheduled task.
*/
class cut_my_toe_nails extends \core\task\scheduled_task {
/**
* Return the task's name as shown in admin screens.
*
* @return string
*/
public function get_name() {
return get_string('cutmytoenails', 'mod_hygene');
}
/**
* Execute the task.
*/
public function execute() {
// Apply fungus cream.
// Apply chainsaw.
// Apply olive oil.
echo 'do';
}
}
And there is /mod_hygene/db/tasks.php:
$tasks = [
[
'classname' => 'mod_hygene\task\cut_my_toe_nails',
'blocking' => 0,
'minute' => '*',
'hour' => '*',
'day' => '*',
'month' => '1,7',
'dayofweek' => '*',
],
];
As you see, the task should run every minute. I run my moodle container via terminal with
docker-compose up -d --build moodle
In the terminal I should see 'do' printed every minute. But, I am not seeing anything. I hovered to Site Administration/Server/Scheduled Tasks. There I am not seeing this task. But I checked in Site Administration/Plugins/Plugins Overview and could find local_mod_hygene in the Local Plugins.
Can anyone help me with it? Do I need to make some changes to the Dockerfile as well?