From 0a25fd88d64773e3da0535edfaa536d20a54e7f5 Mon Sep 17 00:00:00 2001 From: Patrick Winnertz Date: Fri, 23 Aug 2024 08:50:10 +0200 Subject: [PATCH] Just set the status of the cronjob if the job was run or was disabled. --- application/controllers/Cron.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/controllers/Cron.php b/application/controllers/Cron.php index 125ee37de..79b4c1b36 100644 --- a/application/controllers/Cron.php +++ b/application/controllers/Cron.php @@ -75,6 +75,7 @@ class cron extends CI_Controller { $cronjob = $this->cronexpression; $dt = new DateTime(); $isdue = $cronjob->isMatching($dt); + $set_status = false; $next_run = $cronjob->getNext(); $next_run_date = date('Y-m-d H:i:s', $next_run); @@ -108,6 +109,7 @@ class cron extends CI_Controller { echo "ERROR: Something went wrong with " . $cron->id . "; Message: " . $crun . "\n"; $status = 'failed'; } + $set_status = true; } else { $isdue_result = 'false'; echo "CRON: " . $cron->id . " -> is due: " . $isdue_result . " -> Next Run: " . $next_run_date . "\n"; @@ -116,11 +118,14 @@ class cron extends CI_Controller { } else { echo 'CRON: ' . $cron->id . " is disabled. skipped..\n"; $status = 'disabled'; + $set_status = true; // Set the next_run timestamp to null to indicate in the view/database that this cron is disabled $this->cron_model->set_next_run($cron->id, null); } - $this->cron_model->set_status($cron->id, $status); + if ($set_status == true) { + $this->cron_model->set_status($cron->id, $status); + } $this->cronexpression = null; }