function drush_ultimate_cron_cron_list in Ultimate Cron 8
Same name and namespace in other branches
- 8.2 ultimate_cron.drush.inc \drush_ultimate_cron_cron_list()
- 6 ultimate_cron.drush.inc \drush_ultimate_cron_cron_list()
- 7.2 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 100 - Drush commands for Ultimate Cron!
Code
function drush_ultimate_cron_cron_list($type = 'all') {
$module = drush_get_option('module');
$module = $module ? explode(",", $module) : array();
// Get hooks and their data
$hooks = ultimate_cron_get_hooks();
$data = _ultimate_cron_preload_cron_data();
$jobs = array();
$modules = array();
foreach ($hooks as $function => $hook) {
if (!$module || $module == $hook['module']) {
$modules[$hook['module']][$function] = $hook;
}
}
foreach ($hooks as $function => &$hook) {
if ($module && !in_array($hook['module'], $module)) {
continue;
}
$hook['settings'] = $data[$function]['settings'] + $hook['settings'];
$hook['background_process'] = $data[$function]['background_process'];
$hook['log'] = ultimate_cron_get_log($function);
switch ($type) {
case 'enabled':
if (!empty($hook['settings']['enabled'])) {
$jobs[] = $hook;
}
break;
case 'disabled':
if (empty($hook['settings']['enabled'])) {
$jobs[] = $hook;
}
break;
case 'running':
if (!empty($data[$hook['function']]['background_process'])) {
$jobs[] = $hook;
}
break;
case 'unsafe':
if (!empty($hook['unsafe'])) {
$jobs[] = $hook;
}
break;
case 'failed':
if (isset($hook['log']['status']) && empty($hook['log']['status'])) {
$jobs[] = $hook;
}
break;
case 'all':
default:
$jobs[] = $hook;
}
}
$table = array();
$table[] = array(
'',
dt('Module'),
dt('Function'),
dt('Rules'),
dt('Start'),
dt('Duration'),
);
foreach ($jobs as $hook) {
$legend = '';
if (!empty($hook['background_process'])) {
$legend .= 'R';
$hook['log']['start'] = $hook['background_process']->start;
$hook['log']['end'] = microtime(TRUE);
}
if (empty($hook['settings']['enabled'])) {
$legend .= 'D';
}
$start = isset($hook['log']['start']) ? format_date((int) $hook['log']['start'], 'custom', 'Y-m-d H:i:s') : dt('N/A');
$end = isset($hook['log']['end']) ? gmdate('H:i:s', (int) ($hook['log']['end'] - $hook['log']['start'])) : dt('N/A');
$rules = $hook['settings']['rules'];
$table[] = array(
$legend,
$hook['module'],
$hook['function'],
implode("\n", $rules),
$start,
$end,
);
}
drush_print_table($table);
}