Just set the status of the cronjob if the job was run or was disabled.

This commit is contained in:
Patrick Winnertz
2024-08-23 08:50:10 +02:00
parent 91944570db
commit 0a25fd88d6

View File

@@ -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;
}