Skip to content
Snippets Groups Projects
Commit 08ba875c authored by Marius Burkard's avatar Marius Burkard
Browse files

Merge branch '5823-repair-stale-cronjobs' into 'develop'

remove stale "running" cronjobs

Closes #5823

See merge request ispconfig/ispconfig3!1289
parents 5b168ca4 8dc4ce14
No related branches found
No related tags found
No related merge requests found
...@@ -99,6 +99,13 @@ class cronjob { ...@@ -99,6 +99,13 @@ class cronjob {
if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onPrepare() for class " . get_class($this) . "\n"; if($conf['log_priority'] <= LOGLEVEL_DEBUG) print "Called onPrepare() for class " . get_class($this) . "\n";
// check the run time and values for this job // check the run time and values for this job
// remove stale cronjobs
$data = $app->db->queryAllRecords("SELECT `last_run` FROM `sys_cron` WHERE `name` = ? AND (`last_run` IS NOT NULL AND `last_run` < DATE_SUB(NOW(), INTERVAL 24 HOUR)) AND `running` = 1", get_class($this));
foreach ($data as $rec) {
if($conf['log_priority'] <= LOGLEVEL_WARN) print "Removing stale sys_cron entry for ".get_class($this)." (last run ".$rec['last_run'].")\n";
$app->db->query("DELETE FROM `sys_cron` WHERE `name` = ? AND `last_run` = ? AND `running` = 1", $rec['name'], $rec['last_run']);
}
// get previous run data // get previous run data
$data = $app->db->queryOneRecord("SELECT `last_run`, `next_run`, IF(`last_run` IS NOT NULL AND `last_run` < DATE_SUB(NOW(), INTERVAL 24 HOUR), 0, `running`) as `running` FROM `sys_cron` WHERE `name` = ?", get_class($this)); $data = $app->db->queryOneRecord("SELECT `last_run`, `next_run`, IF(`last_run` IS NOT NULL AND `last_run` < DATE_SUB(NOW(), INTERVAL 24 HOUR), 0, `running`) as `running` FROM `sys_cron` WHERE `name` = ?", get_class($this));
if($data) { if($data) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment