Skip to content

feat(cron): allow excluding background job classes via config.php - #65931

Open
MarioPym wants to merge 1 commit into
nextcloud:masterfrom
MarioPym:feat/cron-excluded-job-classes
Open

MarioPym wants to merge 1 commit into
nextcloud:masterfrom
MarioPym:feat/cron-excluded-job-classes

Conversation

@MarioPym

Copy link
Copy Markdown

Summary

On large instances, it is sometimes necessary to prevent a specific background job class from executing (for example, if a job consumes too many resources or is already handled by an external process) without disabling the app that registered it. Currently, the only workaround is deleting the job from oc_jobs, which causes the app to re-register it upon the next upgrade or app activation.

This change introduces the excluded_jobs system configuration key, which accepts a list of job class names. JobList::getNext() skips any jobs matching these classes, preventing them from being picked up by cron, webcron, AJAX, or occ background-job:worker. The jobs remain registered in the database and can still be triggered manually via occ background-job:execute. Leading backslashes in class names are supported, and the new key has been documented in config.sample.php.

How to test

  1. occ config:system:set excluded_jobs 0 --value='OCA\Files\BackgroundJob\DeleteOrphanedItems'
  2. Make that job due (e.g. set its last_run and last_checked to 0 in oc_jobs) and run php cron.php.
    • Before: the job runs.
    • After: the job is skipped; the rest of the jobs run as usual.
  3. occ config:system:delete excluded_jobs and run cron again: the job runs.

Unit tests: tests/lib/BackgroundJob/JobListTest.php.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Mario Alfonso Pym Mejía <pymm@hitss.com>
@MarioPym
MarioPym requested a review from a team as a code owner October 26, 2026 15:13
@MarioPym
MarioPym requested review from Altahrim, provokateurin, salmart-dev and sorbaugh and removed request for a team October 26, 2026 15:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant