summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-04-21 18:23:15 +0200
committerVincent Petry <pvince81@owncloud.com>2016-04-21 18:23:15 +0200
commit37f6b9eaf71bdfcae26a224b282908a128ef1803 (patch)
treea95031e821a24fa8037ff02c9471ff0b42425b0f
parent6e4a28ae869a2ef1f4cf53b9a521a4f11700f2d7 (diff)
parente252967e8322c3492d6381dc99a4f2ee6e3ece31 (diff)
downloadnextcloud-server-37f6b9eaf71bdfcae26a224b282908a128ef1803.tar.gz
nextcloud-server-37f6b9eaf71bdfcae26a224b282908a128ef1803.zip
Merge pull request #24145 from owncloud/limit-cron-execution-time
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 f0dde4fea7f..c4bc9e9667c 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