Cronjobs

If your Module needs to receive big amounts of data from external servers or process lots of data, it might be neccesary to do this asynchroniously, not at the moment the user actually needs that data.

That's why the Incluble platform supports cronjobs.

Setting up cronjobs

Adding a cronjob is as simple as adding a new controller to your module.json file.

module.json

{
"controllers": {
"cron-60": "cron.php"
},
...
}

The above example will create a cron job which runs every 60 minutes. You can change this value to any value you want. It is also possible to create multiple cronjobs, but not two with the same interval.

The maximum number of cronjobs per module is theoretically unlimited, but please don’t use more cronjobs then neccesary. Also try to use as big of an interval as possible for the best performance.

Class availability

Most of the PHP classes in the [module-api Module API] are also available in cronjobs, with the following exceptions:

$this->user is not available because the cronjob is called on a Community-level, not for an individual user.

$this->request only contains the method variable and $this->response is unavailable, because there isn’t a HTTP request when executing a cronjob.

$this->site->theme is missing.

You can still access the Site, Storage and Language classes, along with some others.