function drush_ultimate_cron_cron_list in Ultimate Cron 7.2
Same name and namespace in other branches
- 8.2 ultimate_cron.drush.inc \drush_ultimate_cron_cron_list()
- 8 ultimate_cron.drush.inc \drush_ultimate_cron_cron_list()
- 6 ultimate_cron.drush.inc \drush_ultimate_cron_cron_list()
- 7 ultimate_cron.drush.inc \drush_ultimate_cron_cron_list()
List cron jobs.
File
- ./
ultimate_cron.drush.inc, line 173 - Drush commands for Ultimate Cron!
Code
function drush_ultimate_cron_cron_list() {
$module = drush_get_option('module');
$enabled = drush_get_option('enabled');
$disabled = drush_get_option('disabled');
$behind = drush_get_option('behind');
$extended = drush_get_option('extended');
$statuses = drush_get_option('status');
$scheduled = drush_get_option('scheduled');
$showname = drush_get_option('name');
$module = $module ? explode(",", $module) : array();
$statuses = $statuses ? explode(",", $statuses) : array();
$jobs = _ultimate_cron_job_load_all();
$table = array();
$table[] = array(
'',
dt('Module'),
dt('Title'),
dt('Scheduled'),
dt('Started'),
dt('Duration'),
dt('Status'),
);
$class = _ultimate_cron_get_class('job');
$lock_ids = $class::isLockedMultiple($jobs);
$log_entries = $class::loadLatestLogEntries($jobs);
$progresses = $class::getProgressMultiple($jobs);
$print_legend = FALSE;
foreach ($jobs as $name => $job) {
if ($module && !in_array($job->hook['module'], $module)) {
continue;
}
if ($enabled && !empty($job->disabled)) {
continue;
}
if ($disabled && empty($job->disabled)) {
continue;
}
if ($scheduled && !$job
->isScheduled()) {
continue;
}
$legend = '';
if (!empty($job->disabled)) {
$legend .= 'D';
$print_legend = TRUE;
}
$job->lock_id = $lock_ids[$job->name];
$job->log_entry = $log_entries[$job->name];
$job->progress = $progresses[$job->name];
if ($job->log_entry->lid && $job->lock_id && $job->log_entry->lid !== $job->lock_id) {
$job->log_entry = $job
->loadLogEntry($job->lock_id);
}
if ($time = $job
->isBehindSchedule()) {
$legend .= 'B';
$print_legend = TRUE;
}
if ($behind && !$time) {
continue;
}
if ($job->lock_id && $job->log_entry->lid == $job->lock_id) {
$legend .= 'R';
list($null, $status) = $job
->getPlugin('launcher')
->formatRunning($job);
$print_legend = TRUE;
}
elseif ($job->log_entry->start_time && !$job->log_entry->end_time) {
list($null, $status) = $job
->getPlugin('launcher')
->formatUnfinished($job);
}
else {
list($null, $status) = $job->log_entry
->formatSeverity();
}
if ($statuses && !in_array($status, $statuses)) {
continue;
}
$progress = $job->lock_id ? $job
->formatProgress() : '';
$table[$name][] = $legend;
$table[$name][] = $job
->getModuleName();
$table[$name][] = $showname ? $job->name : $job->title;
$table[$name][] = $job
->getPlugin('scheduler')
->formatLabel($job);
$table[$name][] = $job->log_entry
->formatStartTime();
$table[$name][] = $job->log_entry
->formatDuration() . ' ' . $progress;
$table[$name][] = $status;
if ($extended) {
$table['extended:' . $name][] = '';
$table['extended:' . $name][] = '';
$table['extended:' . $name][] = $job->name;
$table['extended:' . $name][] = $job
->getPlugin('scheduler')
->formatLabelVerbose($job);
$table['extended:' . $name][] = $job->log_entry->init_message;
$table['extended:' . $name][] = $job->log_entry->message;
}
}
drush_print_table($table);
if ($print_legend) {
drush_print("\n" . dt('Legend: D = Disabled, R = Running, B = Behind schedule'));
}
}