About scheduled tasks and cron
In Totara 2.7 the way in which cron executed was changed. Prior to 2.7 cron executed several functions one after the other and most tasks executed every time cron ran. The recommendation was to configure cron to run only at times when you did not expect the server to be under load. For a business running it outside of business hours for instance.
In Totara 2.7 scheduled tasks were introduced. Each function that cron executed was split off into its own task. A site administrator can configure when each task is run and how frequently it gets run. The recommendation was changed to run cron very frequently every minute or every five minutes. Each time cron ran it would execute only the tasks the were due to be run.
The affects what we do as both developers and for support when trying to tests and diagnose customer reports.
The following sections explain how to run cron and how to run individual scheduled tasks.
This will execute cron - it won't necessarily execute all of the
scheduled tasks as there time configuration is still needed.
If you NEED to run a task then you should use the following.
Running a specific scheduled task
- On the command line
php admin/tool/task/cli/schedule_task.php --execute FULLNAMEOFTASK
FULLNAMEOFTASK is the full name of the task - you can find it on the scheduled tasks page in the admin interface `Site administration ▶ Server ▶ Scheduled tasks`
The name you need is the bit starting with a forward slash () not the pretty English name.
If you used "\block_totara_stats\task\update_totara_stats_task" you would execute the task to update stats for the Totara block.
php admin/tool/task/cli/schedule_task.php --execute \\block_totara_stats\\task\\update_totara_stats_task
If you execute a scheduled task like this it is run regardless of the the time configuration the admin has set. It is always executed. Very handy for testing.
At present there is no way to execute a specific scheduled task from the browser, you can only do it via the console.
Running cron on Moodle 2.6 and lower
- In your browser through settings
Browse to `Site administration ▶ Server ▶ Cron` and press execute.
- In your browser directly
change your url to http://yoursite.com/admin/cron.php
- On the command line