function tripal_get_active_jobs

2.x tripal_get_active_jobs($modulename = NULL)

Returns a list of jobs that are active.


$modulename: Limit the list returned to those that were added by a specific module. If no module name is provided then all active jobs are returned.

Return value

An array of objects where each object describes a tripal job. If no jobs were found then an empty array is returned. Each object will have the following members:

  • job_id: The unique ID number for the job.
  • uid: The ID of the user that submitted the job.
  • job_name: The human-readable name of the job.
  • modulename: The name of the module that submitted the job.
  • callback: The callback function to be called when the job is run.
  • arguments: An array of arguments to be passed to the callback function.
  • progress: The percent progress of completion if the job is running.
  • status: The status of the job: Waiting, Completed, Running or Cancelled.
  • submit_date: The UNIX timestamp when the job was submitted.
  • start_time: The UNIX timestamp for when the job started running.
  • end_time: The UNIX timestampe when the job completed running.
  • error_msg: Any error message that occured during execution of the job.
  • prirotiy: The execution priority of the job (value between 1 and 10)

Related topics

1 call to tripal_get_active_jobs()
1 string reference to 'tripal_get_active_jobs'


tripal_core/api/, line 574
Tripal offers a job management subsystem for managing tasks that may require an extended period of time for completion.


function tripal_get_active_jobs($modulename = NULL) {
  $query = db_select('tripal_jobs', 'TJ')
    ->fields('TJ', array('job_id', 'uid', 'job_name', 'modulename', 'callback',
      'arguments', 'progress', 'status', 'submit_date', 'start_time',
      'end_time', 'error_msg', 'priority'));
  if ($modulename) {
    "TJ.modulename = :modulename and NOT (TJ.status = 'Completed' or TJ.status = 'Cancelled')", 
    array(':modulename' => $modulename)
  $results = $query->execute();

  $jobs = array();
  while ($job = $results->fetchobject()) {
    $jobs->arguments = unserialize($job->arguments);
    $jobs[] = $job;
  return $jobs;