Do not create a loop that generates thousands of jobs
This commit is contained in:
parent
476720ada9
commit
5238fc3f54
13
cron.php
13
cron.php
|
@ -130,11 +130,20 @@ try {
|
||||||
|
|
||||||
// Work
|
// Work
|
||||||
$jobList = \OC::$server->getJobList();
|
$jobList = \OC::$server->getJobList();
|
||||||
$jobs = $jobList->getAll();
|
|
||||||
foreach ($jobs as $job) {
|
$executedJobs = [];
|
||||||
|
while ($job = $jobList->getNext()) {
|
||||||
|
if (isset($executedJobs[$job->getId()])) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$logger->debug('Run job with ID ' . $job->getId(), ['app' => 'cron']);
|
$logger->debug('Run job with ID ' . $job->getId(), ['app' => 'cron']);
|
||||||
$job->execute($jobList, $logger);
|
$job->execute($jobList, $logger);
|
||||||
$logger->debug('Finished job with ID ' . $job->getId(), ['app' => 'cron']);
|
$logger->debug('Finished job with ID ' . $job->getId(), ['app' => 'cron']);
|
||||||
|
|
||||||
|
$jobList->setLastJob($job);
|
||||||
|
$executedJobs[$job->getId()] = true;
|
||||||
|
unset($job);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlock the file
|
// unlock the file
|
||||||
|
|
Loading…
Reference in New Issue