Make sure that CLI cron doesn't run for ever, but makes use of the next spawn

This commit is contained in:
Joas Schilling 2016-04-21 10:33:44 +02:00
parent 02ecd040e6
commit e252967e83
No known key found for this signature in database
GPG Key ID: 70A0B324C41C0946
1 changed files with 8 additions and 0 deletions

View File

@ -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