IJobList
Interface IJobList
This interface provides functions to register background jobs
To create a new background job create a new class that inherits from either \OC\BackgroundJob\Job, \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using ->add($job, $argument), $argument will be passed to the run() function of the job when the job is executed.
A regular job will be executed every time cron.php is run, a QueuedJob will only run once and a TimedJob will only run at a specific interval which is to be specified in the constructor of the job by calling $this->setInterval($interval) with $interval in seconds.
Tags
Table of Contents
- add() : mixed
- Add a job to the list
- getAll() : \OCP\BackgroundJob\IJob[]
- get all jobs in the list
- getById() : IJob|null
- getLastJob() : int
- get the id of the last ran job
- getNext() : IJob|null
- get the next job in the list
- has() : bool
- check if a job is in the list
- remove() : mixed
- Remove a job from the list
- setExecutionTime() : mixed
- set the run duration of $job
- setLastJob() : mixed
- set the job that was last ran to the current time
- setLastRun() : mixed
- set the lastRun of $job to now
- unlockJob() : mixed
- Remove the reservation for a job
Methods
add()
Add a job to the list
public
add(IJob|string $job[, mixed $argument = null ]) : mixed
Parameters
- $job : IJob|string
- $argument : mixed = null
-
The argument to be passed to $job->run() when the job is exectured
Tags
Return values
mixed —getAll()
get all jobs in the list
public
getAll() : \OCP\BackgroundJob\IJob[]
Tags
Return values
\OCP\BackgroundJob\IJob[] —getById()
public
getById(int $id) : IJob|null
Parameters
- $id : int
Tags
Return values
IJob|null —getLastJob()
get the id of the last ran job
public
getLastJob() : int
Tags
Return values
int —getNext()
get the next job in the list
public
getNext() : IJob|null
Tags
Return values
IJob|null —has()
check if a job is in the list
public
has(IJob|string $job, mixed $argument) : bool
Parameters
- $job : IJob|string
- $argument : mixed
Tags
Return values
bool —remove()
Remove a job from the list
public
remove(IJob|string $job[, mixed $argument = null ]) : mixed
Parameters
- $job : IJob|string
- $argument : mixed = null
Tags
Return values
mixed —setExecutionTime()
set the run duration of $job
public
setExecutionTime(IJob $job, $timeTaken) : mixed
Parameters
- $job : IJob
- $timeTaken :
Tags
Return values
mixed —setLastJob()
set the job that was last ran to the current time
public
setLastJob(IJob $job) : mixed
Parameters
- $job : IJob
Tags
Return values
mixed —setLastRun()
set the lastRun of $job to now
public
setLastRun(IJob $job) : mixed
Parameters
- $job : IJob
Tags
Return values
mixed —unlockJob()
Remove the reservation for a job
public
unlockJob(IJob $job) : mixed
Parameters
- $job : IJob