$_jobs
$_jobs : array<mixed,\midcom_baseclasses_components_cron_handler>
The list of jobs to run. See the class introduction for a more precise definition of these keys.
This is the handling class of the cron service. When executed, it checks all component manifests for cron jobs and runs them sequentially. The components are processed in the order they are returned by the component loader, the jobs of a single component are run in the order they are listed in the configuration array.
Cron Job configuration
Each cron job is defined by an associative array containing the following keys:
The Cron service uses customdata section of the manifest, using the key midcom.services.cron as you might have guessed. So, an example cron entry could look like this:
'customdata' => Array
(
'midcom.services.cron' => Array
(
Array
(
'handler' => 'net_nehmer_static_cron_test',
'recurrence' => MIDCOM_CRON_MINUTE,
)
),
),
A simple (and useless) handler class would look like this:
<?php
class net_nehmer_static_cron_test extends midcom_baseclasses_components_cron_handler
{
function _on_initialize()
{
return true;
}
function execute()
{
$this->print_error("Executing...");
$this->print_error(strftime('%x %X'));
}
}
Cron Job implementation suggestions
You should keep output to stdout to an absolute minimum. Normally, no output whatsoever should be made, as the cron service itself is invoked using some kind of Cron Daemon. Only if you output nothing, no status mail will be generated by cron.
Launching MidCOM Cron from a System Cron
You need to request the midcom-exec-midcom/cron.php page of your website to have cron running. Lynx or the GET command line tools can be used, for example, to retrieve the cron page:
lynx -source http://your.site.com/midcom-exec-midcom/cron.php GET http://your.site.com/midcom-exec-midcom/cron.php
The script produces no output unless anything goes wrong.
$_jobs : array<mixed,\midcom_baseclasses_components_cron_handler>
The list of jobs to run. See the class introduction for a more precise definition of these keys.