From e252967e8322c3492d6381dc99a4f2ee6e3ece31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 21 Apr 2016 10:33:44 +0200 Subject: [PATCH] Make sure that CLI cron doesn't run for ever, but makes use of the next spawn --- cron.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cron.php b/cron.php index f0dde4fea7..c4bc9e9667 100644 --- a/cron.php +++ b/cron.php @@ -131,6 +131,10 @@ try { // Work $jobList = \OC::$server->getJobList(); + // We only ask for jobs for 14 minutes, because after 15 minutes the next + // system cron task should spawn. + $endTime = time() + 14 * 60; + $executedJobs = []; while ($job = $jobList->getNext()) { if (isset($executedJobs[$job->getId()])) { @@ -144,6 +148,10 @@ try { $jobList->setLastJob($job); $executedJobs[$job->getId()] = true; unset($job); + + if (time() > $endTime) { + break; + } } // unlock the file