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…
This commit is contained in:
commit
37f6b9eaf7
8
cron.php
8
cron.php
|
@ -131,6 +131,10 @@ try {
|
||||||
// Work
|
// Work
|
||||||
$jobList = \OC::$server->getJobList();
|
$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 = [];
|
$executedJobs = [];
|
||||||
while ($job = $jobList->getNext()) {
|
while ($job = $jobList->getNext()) {
|
||||||
if (isset($executedJobs[$job->getId()])) {
|
if (isset($executedJobs[$job->getId()])) {
|
||||||
|
@ -144,6 +148,10 @@ try {
|
||||||
$jobList->setLastJob($job);
|
$jobList->setLastJob($job);
|
||||||
$executedJobs[$job->getId()] = true;
|
$executedJobs[$job->getId()] = true;
|
||||||
unset($job);
|
unset($job);
|
||||||
|
|
||||||
|
if (time() > $endTime) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlock the file
|
// unlock the file
|
||||||
|
|
Loading…
Reference in New Issue