Skip to content

Commit

Permalink
fix: do not check against current time
Browse files Browse the repository at this point in the history
  • Loading branch information
rugbymauri committed Aug 9, 2023
1 parent 4df1fb0 commit b16fd8b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Manager/ExecutionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public function isRunNeeded(CronInterface $cronJob): bool

// Get next execution date
$nextExecutionDate = $this->getNextExecutionDate($cronJob);
$now = new \DateTime();
if ($nextExecutionDate > $now) {
if (!$nextExecutionDate) {
$this->logger->debug(sprintf('%s do not need to run. Next run at %s', $cronJob::class, $nextExecutionDate->format('Y-m-d H:i:s')));

return false;
Expand All @@ -129,7 +128,7 @@ public function isRunNeeded(CronInterface $cronJob): bool

// Check if previous execution still running
$lastExecution = $this->getLastExecution($cronJob);
if ($lastExecution->getState() === Execution::STATE_RUNNING) {
if ($lastExecution && $lastExecution->getState() === Execution::STATE_RUNNING) {
$this->logger->debug(sprintf('%s has a still running previous execution. Skipping it until previous execution finished.', $cronJob::class));

return false;
Expand Down

0 comments on commit b16fd8b

Please sign in to comment.