To declare a task, you need to specify its name and frequency in seconds using the taches_generales_cron
pipeline:
function myplugin_general_cron_jobs($taches){
$taches['nom'] = 24*3600; // once per day, every day
}
This task will be called at the appropriate time. The processes are placed in a file in the genie/
directory, with the same name as the (name.php
) task and including a genie_name_dist()
function.
The function is passed the date at which it last performed that task as an argument. It must return a number:
- null, if the task has nothing to do
- positive, if the task has been run
- negative, if the task started but could not complete. This makes it possible to run tasks in batches (to avoid timeouts on PHP script executions because the processes run too long). In such cases, the negative number indicated corresponds to the number of seconds of interval before the next scheduled task run.