IJobList

interface OCP\BackgroundJob\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.
Implemented by:OC\BackgroundJob\JobList
Source:lib/public/BackgroundJob/IJobList.php#47

Methods

public OCP\BackgroundJob\IJobList::add($job, $argument=null)
Add a job to the list
Source:

lib/public/BackgroundJob/IJobList.php#55

Parameters:
  • $job (OCP\BackgroundJob\IJob | string)
  • $argument (mixed) The argument to be passed to $job->run() when the job is exectured
Since:

7.0.0

public OCP\BackgroundJob\IJobList::remove($job, $argument=null)
Remove a job from the list
Source:

lib/public/BackgroundJob/IJobList.php#64

Parameters:
Since:

7.0.0

public OCP\BackgroundJob\IJobList::has($job, $argument)
check if a job is in the list
Source:

lib/public/BackgroundJob/IJobList.php#74

Parameters:
Returns:

bool

Since:

7.0.0

public OCP\BackgroundJob\IJobList::getAll()
get all jobs in the list
Source:lib/public/BackgroundJob/IJobList.php#84
Returns:\OCP\BackgroundJob\IJob[]
Since:7.0.0
Deprecated:9.0.0 - This method is dangerous since it can cause load and memory problems when creating too many instances.
public OCP\BackgroundJob\IJobList::getNext()
get the next job in the list
Source:lib/public/BackgroundJob/IJobList.php#92
Returns:\OCP\BackgroundJob\IJob | null
Since:7.0.0
public OCP\BackgroundJob\IJobList::getById($id)
Source:

lib/public/BackgroundJob/IJobList.php#99

Parameters:
  • $id (int)
Returns:

\OCP\BackgroundJob\IJob | null

Since:

7.0.0

public OCP\BackgroundJob\IJobList::setLastJob($job)
set the job that was last ran to the current time
Source:

lib/public/BackgroundJob/IJobList.php#107

Parameters:
Since:

7.0.0

public OCP\BackgroundJob\IJobList::unlockJob($job)
Remove the reservation for a job
Source:

lib/public/BackgroundJob/IJobList.php#115

Parameters:
Since:

9.1.0

public OCP\BackgroundJob\IJobList::setLastRun($job)
set the lastRun of $job to now
Source:

lib/public/BackgroundJob/IJobList.php#123

Parameters:
Since:

7.0.0

public OCP\BackgroundJob\IJobList::setExecutionTime($job, $timeTaken)
set the run duration of $job
Source:

lib/public/BackgroundJob/IJobList.php#132

Parameters:
Since:

12.0.0