diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php index 1a0e4cba2..f3c3d0314 100644 --- a/setup/backup.class.inc.php +++ b/setup/backup.class.inc.php @@ -1,5 +1,5 @@ LogError("Failed to execute: $sCommandDisplay. The command returned:$iRetCode"); foreach($aOutput as $sLine) { diff --git a/webservices/cron.php b/webservices/cron.php index 588f687ba..456b37a61 100644 --- a/webservices/cron.php +++ b/webservices/cron.php @@ -1,5 +1,5 @@ Process($iTimeLimit); - $fDuration = microtime(true) - $fStart; - if ($oTask->Get('total_exec_count') == 0) - { - // First execution - $oTask->Set('first_run_date', $oNow->format('Y-m-d H:i:s')); - } - $oTask->ComputeDurations($fDuration); // does increment the counter and compute statistics - $oTask->Set('latest_run_date', $oNow->format('Y-m-d H:i:s')); - - $oRefClass = new ReflectionClass(get_class($oProcess)); - if ($oRefClass->implementsInterface('iScheduledProcess')) - { - // Schedules process do repeat at specific moments - $oPlannedStart = $oProcess->GetNextOccurrence(); - } - else - { - // Background processes do repeat periodically - $oPlannedStart = new DateTime($oTask->Get('latest_run_date')); - // Let's assume that the task was started exactly when planned so that the schedule does no shift each time - // this allows to schedule a task everyday "around" 11:30PM for example - $oPlannedStart->modify('+'.$oProcess->GetPeriodicity().' seconds'); - $oEnd = new DateTime(); - if ($oPlannedStart->format('U') < $oEnd->format('U')) - { - // Huh, next planned start is already in the past, shift it of the periodicity ! - $oPlannedStart = $oEnd->modify('+'.$oProcess->GetPeriodicity().' seconds'); - } - } - - $oTask->Set('next_run_date', $oPlannedStart->format('Y-m-d H:i:s')); - $oTask->DBUpdate(); } catch(Exception $e) { - $sMessage = 'Processing failed, the following exception occured: '.$e->getMessage(); + $sMessage = 'Processing failed with message: '.$e->getMessage(); } - return $sMessage; + $fDuration = microtime(true) - $fStart; + if ($oTask->Get('total_exec_count') == 0) + { + // First execution + $oTask->Set('first_run_date', $oNow->format('Y-m-d H:i:s')); + } + $oTask->ComputeDurations($fDuration); // does increment the counter and compute statistics + $oTask->Set('latest_run_date', $oNow->format('Y-m-d H:i:s')); + + $oRefClass = new ReflectionClass(get_class($oProcess)); + if ($oRefClass->implementsInterface('iScheduledProcess')) + { + // Schedules process do repeat at specific moments + $oPlannedStart = $oProcess->GetNextOccurrence(); + } + else + { + // Background processes do repeat periodically + $oPlannedStart = new DateTime($oTask->Get('latest_run_date')); + // Let's assume that the task was started exactly when planned so that the schedule does no shift each time + // this allows to schedule a task everyday "around" 11:30PM for example + $oPlannedStart->modify('+'.$oProcess->GetPeriodicity().' seconds'); + $oEnd = new DateTime(); + if ($oPlannedStart->format('U') < $oEnd->format('U')) + { + // Huh, next planned start is already in the past, shift it of the periodicity ! + $oPlannedStart = $oEnd->modify('+'.$oProcess->GetPeriodicity().' seconds'); + } + } + + $oTask->Set('next_run_date', $oPlannedStart->format('Y-m-d H:i:s')); + $oTask->DBUpdate(); + return $sMessage; } function CronExec($oP, $aProcesses, $bVerbose)