An extension can run some of its routines periodically, for example,
every 10 minutes, every hour, or daily. This scheduler interface manages
the crontab utility on Linux and the Task Scheduler application on
Windows. The interface is presented by two classes -
pm_Scheduler
and
pm_Scheduler_Task.
The first class represents a task manager and the second class
represents a task.
To successfully schedule a task, your code must meet the following
requirements:
- Put a scheduled task under
/plib/scripts/relatively to the
extension’s root directory. - Initialize the extension context (pm_Context::init) before
scheduling a task. - Schedule the task using pm_Scheduler and pm_Scheduler_Task.
Examples
This sample code adds a periodic task to the scheduler. The following
methods of
pm_Scheduler_Task are
used:
The code can look as follows:
$task = new pm_Scheduler_Task();
$task->setSchedule(array(
'minute' => '0,4,9,14,19,24,29,34,39,44,49,54,59',
'hour' => '*',
'dom' => '*',
'month' => '*',
'dow' => '*'
));
$task->setCmd(…