Running multiple task with one command …

Let’s say you have several individual task you’d like to run … but
not one at a time … too time consuming.

Example … several ‘cleanup’ task.
Create a file called ‘cleanup’ in admin/cli/tool/cli/
It consist of one liners that are the commands one would have keyed in
one at a time.

Looks like:

php schedule_task.php –execute=”\logstore_legacy\task\cleanup_task”
php schedule_task.php –execute=”\logstore_standard\task\cleanup_task”
php schedule_task.php –execute=”\core\task\file_trash_cleanup_task”
php schedule_task.php –execute=”\core\task\messaging_cleanup_task”
php schedule_task.php –execute=”\core\task\password_reset_cleanup_task”
php schedule_task.php –execute=”\core\task\session_cleanup_task”
php schedule_task.php –execute=”\core_files\task\conversion_cleanup_task”
php schedule_task.php –execute=”\tool_recyclebin\task\cleanup_category_bin”
php schedule_task.php –execute=”\tool_recyclebin\task\cleanup_course_bin”

make the ‘cleanup’ file executable.

To execute use ‘source cleanup’

Each task will be executed and it’s output displayed … example:

Execute scheduled task: Cleanup of temporary records for file conversions. (core_files\task\conversion_cleanup_task)
… used 2 dbqueries
… used 0.0052680969238281 seconds
Scheduled task complete: Cleanup of temporary records for file conversions. (core_files\task\conversion_cleanup_task)
Execute scheduled task: Cleanup category recycle bin (tool_recyclebin\task\cleanup_category_bin)
… used 1 dbqueries
… used 0.0043408870697021 seconds
Scheduled task complete: Cleanup category recycle bin (tool_recyclebin\task\cleanup_category_bin)
Execute scheduled task: Cleanup course recycle bin (tool_recyclebin\task\cleanup_course_bin)
… used 1 dbqueries
… used 0.0046000480651855 seconds
Scheduled task complete: Cleanup course recycle bin (tool_recyclebin\task\cleanup_course_bin)