/** * Ends a job by handing it over to * * @param Enlight_Components_Cron_Job $job * @return void */ protected function endJob(Enlight_Components_Cron_Job $job) { $now = new Zend_Date(); $now = $now->getTimestamp(); $interval = $job->getInterval(); $next = $job->getNext()->getTimestamp(); do { $next += $interval; } while ($now >= $next); $job->setNext($next); $job->setEnd($now); $this->adapter->updateJob($job); }
/** * Starts a job by handing it over to * * @param Enlight_Components_Cron_Job $job * @return void|bool */ private function startJob(Enlight_Components_Cron_Job $job) { $nextRun = $job->getNext(); // get next Date // Turn clock forward do { $nextRun->addSecond($job->getInterval()); } while ($nextRun->compare(new Zend_Date()) >= 0); $job->setStart(new Zend_Date()); $job->setEnd(null); try { $this->_adapter->updateJob($job); $job->setNext($nextRun); return true; } catch (Exception $e) { return false; } }