Cron job for background jobs is removed in very short intervals

Nextcloud version: 22.2.5
Operating system and version: Ubuntu 20.04.4 LTS
Apache version: Apache/2.4.41 (Ubuntu)
PHP version: 7.4.14 (cli)

The issue you are facing

I realized a few days ago that background jobs have not been running anymore for a week or so. I followed the help links on the settings pages and added a cron job for user www-data as described here.

At first it seemed like everything was back to normal but background jobs stopped running pretty soon after and the cron job list for user www-data was empty again even though I did not delete anything myself.

After some fiddling around, I realized that cron jobs for user www-data somehow always get removed after some arbitrary time (at least I wasn’t able to figure out any regularity here).

Here’s an example of when that happened:

Is this the first time you’ve seen this error?

Yes, this Nextcloud installation has been up and running for many years now and background jobs were running reliably until recently (not sure, when that actually started).


I’m omitting logs for now as this doesn’t feel like “PHP or Apache config related” but I’ll happily provide them in an later comment if needed. Just let me know!


  • What could cause my cron job to disappear?
  • How can I find out what is causing my cron job to disappear?
  • How can I prevent this from happening?


I also posted this question on a few days ago but did not get any response so far.

Are you using a management interface like Plesk, cPanel, Webmin, ISPConfig or similar? Such management interfaces often also manage the cronjobs, thus also removing those that were not set via the management interface. Nextcloud itself does not remove cronjobs.

Automation tools like Puppet, Ansible, Salt, etc. can also overwrite configuration files.

Alternatively you can create a cronjob in /etc/cron.d.

$ cat /etc/cron.d/nextcloud
*/5 * * * * www-data php -f /var/www/web/nextcloud/cron.php

(in /etc/cron.d/ you need to also specify the user)


I’m neither using any mgmt interface, nor one of the automation tools you mentioned. At least not that I’m aware of :see_no_evil:

I’ll create the cronjob via etc/cron.d/nextcloud as you suggested and will let you know.

Thanks for the tip!

@mritzmann Using /etc/cron.d (or /etc/crontab in my case to be precise) seems to have done the job :+1:.

I’m still curious on what actually changes the crontab of user www-data so that I can’t use this anymore, but I won’t be investing any more time on this, so that’ll probably stay an unsolved mystery :man_shrugging:

Thanks for the help!