Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-04-21 11:33:44 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2016-04-21 11:33:44 +0300
commite252967e8322c3492d6381dc99a4f2ee6e3ece31 (patch)
tree7af6a273d62affb2064876901ad3f3b1b23e1242 /cron.php
parent02ecd040e6cd761b9ec30895c5a0fcced55fb699 (diff)
Make sure that CLI cron doesn't run for ever, but makes use of the next spawn
Diffstat (limited to 'cron.php')
-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