Beispiel #1
0
 /**
  * Lists out all available tasks, names only.
  */
 private function listTaskNames()
 {
     $suspended = Settings::get('suspended_tasks', 'cron');
     if (empty($suspended)) {
         $suspended = [];
     }
     $tasks = \Myth\Cron\CronManager::listAll();
     echo CLI::write("\nAvailable Tasks:");
     foreach ($tasks as $alias => $task) {
         $color = 'yellow';
         $extra = '';
         if (in_array($alias, $suspended)) {
             $color = 'blue';
             $extra = "[Suspended]";
         }
         echo CLI::write("\t{$extra} {$alias}", $color);
     }
 }
Beispiel #2
0
 public function testListAllReturnsRelativeTimesInPast()
 {
     CronManager::schedule('task1', '5 minutes', 'library:method');
     CronManager::schedule('task2', '6 minutes', 'library:method');
     CronManager::schedule('task3', '7 minutes', 'library:method');
     $time = strtotime('-5 days');
     $all = CronManager::listAll($time);
     // Must do fancy check since findTimeInterval rounds to current minute...
     $this->assertTrue($all['task1']['next_run'] >= strtotime(date('Y-m-d H:i', $time)));
     $this->assertTrue($all['task1']['prev_run'] < $time);
 }