Development Guide

Cron Plugins

This feature is available for ILIAS 4.4.x+.

With cron plugins custom cron jobs can be added to the system. They will be listed with the default cron jobs in Administration > General Settings > Cron Jobs. Most - if not all - features of cron jobs should be supported for custom cron jobs, too.

Plugin Slot

The plugin slot is named "Cron Hook" (Administration > Plugins > Slots). The corresponding plugin target directory is
Customizing/global/plugins/Services/Cron/CronHook.
 
The plugin base class must extend "ilCronHookPlugin" and implement 3 abstract methods.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
include_once("./Services/Cron/classes/class.ilCronHookPlugin.php");

class ilCronExamplePlugin extends ilCronHookPlugin
{
function getPluginName()
{
return "CronExample";
}

function getCronJobInstances()
{
include_once "class.ilCronExamplePluginJob1.php";
$job = new ilCronExamplePluginJob1();

return array($job);
}

function getCronJobInstance($a_job_id)
{
include_once "class.ilCronExamplePluginJob1.php";
return new ilCronExamplePluginJob1();
}
}
Please note the difference between the 2 cron job instance methods:
  • getCronJobInstances() has to return an array with instances of all cron jobs of the plugin
  • getCronJobInstance($a_job_id) has to return a single instance of the cron job with the given id
All cron jobs have to be an instance of ilCronJob, see Chapter "Cron" in this guide.

Additional Comments

Only custom cron jobs of active plugins will be processed and are listed in the administration. Additional settings for custom cron jobs are supported, but database handling or other methods of persistence have to be done by the plugin itself.