From 67d47d59d37cce40df7aa889d445ead42e46fc35 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 24 Nov 2017 17:36:38 +0200 Subject: [PATCH] Fixed checking if crontab is configured --- application/Espo/Core/Utils/ScheduledJob.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application/Espo/Core/Utils/ScheduledJob.php b/application/Espo/Core/Utils/ScheduledJob.php index 9907cefa5e..2971df0d2b 100644 --- a/application/Espo/Core/Utils/ScheduledJob.php +++ b/application/Espo/Core/Utils/ScheduledJob.php @@ -46,11 +46,11 @@ class ScheduledJob protected $allowedMethod = 'run'; /** - * Last cron run time to check if crontab is configured properly + * Period to check if crontab is configured properly * * @var string */ - protected $lastCronRunTime = '24 hours'; + protected $checkingCronPeriod = '25 hours'; /** * @var array - path to cron job files @@ -208,8 +208,8 @@ class ScheduledJob */ public function isCronConfigured() { - $nowDate = new \DateTime('now', new \DateTimeZone("UTC")); - $startDate = new \DateTime('-' . $this->lastCronRunTime, new \DateTimeZone("UTC")); + $startDate = new \DateTime('-' . $this->checkingCronPeriod, new \DateTimeZone("UTC")); + $endDate = new \DateTime('+' . $this->checkingCronPeriod, new \DateTimeZone("UTC")); $query = " SELECT job.id FROM scheduled_job @@ -217,8 +217,8 @@ class ScheduledJob WHERE scheduled_job.job = 'Dummy' AND scheduled_job.deleted = 0 - AND job.execute_time BETWEEN '". $startDate->format('Y-m-d H:i:s') ."' AND '". $nowDate->format('Y-m-d H:i:s') ."' - AND (job.status IN ('Success', 'Failed') OR (job.status = 'Pending' AND job.execute_time >= '". $nowDate->modify('-1 hour')->format('Y-m-d H:i:s') ."') ) + AND job.execute_time BETWEEN '". $startDate->format('Y-m-d H:i:s') ."' AND '". $endDate->format('Y-m-d H:i:s') ."' + AND job.status IN ('Success', 'Failed', 'Pending') ORDER BY job.execute_time DESC ";