summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-22 17:25:14 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-04-22 17:25:14 +0200
commit3ab41be50679fe1261534e51528da34933d8d99e (patch)
treebbe8aa95310a1baf996580c4d49cdf325458554c
parent4ed979df5fd2c43c63f16c46dda4cf81f739bf7b (diff)
parentdb6b6d832ea7685c46ebaddad5680c5de40af91c (diff)
downloadnextcloud-server-3ab41be50679fe1261534e51528da34933d8d99e.tar.gz
nextcloud-server-3ab41be50679fe1261534e51528da34933d8d99e.zip
Merge pull request #24181 from owncloud/backport-24145-limit-background-job-runtime-8.2
[8.2] Make sure that CLI cron doesn't run for ever, but makes use of the ne…
-rw-r--r--cron.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/cron.php b/cron.php
index 193cd4b835c..d59e0915074 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