From 73d27bc82bba0c0a2e33dc5bb312c18d11a88260 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 17 Aug 2021 20:54:57 +0200 Subject: [PATCH] schedule next run before executing current run --- utils/schedulercli.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/schedulercli.php b/utils/schedulercli.php index 1d55247c3..e0f0ef6c6 100644 --- a/utils/schedulercli.php +++ b/utils/schedulercli.php @@ -84,10 +84,14 @@ foreach($tasks as $task) { if(method_exists($taskobj, 'execute')) { if(!$task->getDisabled() && $task->isDue()) { if($mode == 'run') { - echo get_class($task); + /* Schedule the next run right away to prevent a second execution + * of the task when the cron job of the scheduler is called before + * the last run was finished. The task itself can still be scheduled + * to fast, but this is up to the admin of seeddms. + */ + $task->updateLastNextRun(); if($taskobj->execute($task)) { add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful."); - $task->updateLastNextRun(); } else { add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR); $task->setDisabled(1);