public function JobScheduler::set in Job Scheduler 6
Same name and namespace in other branches
- 7.2 JobScheduler.inc \JobScheduler::set()
- 7 JobScheduler.inc \JobScheduler::set()
Add a job to the schedule, replace any existing job.
A job is uniquely identified by $job = array(callbac, type, id).
@code function callback($job) { // Work off job. // Set next time to be called. If this portion of the code is not // reached for some reason, the scheduler will keep periodically invoking // the callback() with the period value initially specified. $scheduler->set($job); }
Parameters
$job: An array that must contain the following keys: 'callback' - The callback to evoke. 'type' - A string identifier of the type of job. 'id' - A numeric identifier of the job. 'period' - The time when the task should be executed. 'periodic' - True if the task should be repeated periodically.
File
- ./
JobScheduler.inc, line 59 - JobScheduler class.
Class
- JobScheduler
- Handle adding and removing jobs from schedule.
Code
public function set($job) {
$job['last'] = JOB_SCHEDULER_REQUEST_TIME;
$job['next'] = JOB_SCHEDULER_REQUEST_TIME + $job['period'];
$job['scheduled'] = 0;
$this
->remove($job);
drupal_write_record('job_schedule', $job);
}