I have no support/technical question and have seen the support category. (Be aware that direct support questions will be deleted.)
on
Which general topic do you have
Hello.
I’ve found an interesting feature on Nextcloud: occ background-job:worker.
There were some stuck jobs on my server and this tool has really helped me out.
I’ve been using systemd timer, and crontab before that, but after updating to the latest version a week ago background jobs weren’t running. I suspect the Passwords app is the culprit.
Anyway, the problem is resolved after running the worker. But I’ve decided to leave it running for a while and was surprised by how fast the notifications started to arrive. It would take around 15-30 seconds before, but it’s almost instant with the worker.
I’ve asked an LLM to make me a systemd unit and this is what it has come up with:
/etc/systemd/system/nextcloud-worker@.service
[Service]
User=www-data
Group=www-data
ExecStart=/usr/bin/php /var/www/nextcloud/occ background-job:worker
# 1. ALWAYS RESTART
Restart=always
# 2. WAIT 5 SECONDS
# Prevents the worker from respawning instantly and crashing again
# (which would lock up the CPU before you could intervene).
RestartSec=5s
# 3. PREVENT RESTART SPAM (Crash Protection)
# If the worker crashes more than 5 times in 60 seconds,
# systemd will stop trying to restart it for a while.
StartLimitIntervalSec=60
StartLimitBurst=5
#Added later after reading the documentation
#Kills the worker every N seconds to pick up new settings.
RuntimeMaxSec=3600
# Low priority
Nice=19
IOSchedulingClass=idle
PrivateTmp=yes
I didn’t find anything in the documentation. However, you can track down and find a few things on github, here the feature was introduced: https://github.com/nextcloud/server/pull/30359
Feature request for a runner:
On the forum, just an unanswered help request:
If you have broken background jobs, you should also find out which ones are failing and repair them (or report a bug). The oc_jobs table should help you which jobs run when for the last time and how long it took, and of course when it is running the logfiles (and you might have some errors when you call the jobs directly from command line).
Probably needs a general write-up in the Background Jobs section of the Admin Manual (any volunteers?), but there are two spots in the manual where worker mode is documented (because the worker is more often used with these features):