What the message looks like
Last background job execution ran 3 days ago. Something seems wrong.Common causes
- Background jobs set to AJAX or Webcron instead of Cron.
- No crontab entry for the web server user, or the entry is in root's crontab.
- cron.php aborts, e.g. because of APCu in the CLI, the wrong PHP version or memory limit.
- systemd timer disabled or not moved along after a migration.
- Container setup without a separate cron container.
Check
- Show the configured background job mode
sudo -u www-data php /var/www/nextcloud/occ config:app:get core backgroundjobs_mode - Show the web server user's crontab
crontab -u www-data -l - Run cron.php once by hand and see errors
sudo -u www-data php -f /var/www/nextcloud/cron.php; echo "exit $?" - Check existing systemd timers
systemctl list-timers | grep -i nextcloud
Fix
- Set the mode to Cron:
occ background:cron. - Create the crontab for www-data:
*/5 * * * * php -f /var/www/nextcloud/cron.php. - Fix errors from the manual run, e.g. set
apc.enable_cli=1. - Alternatively use a systemd timer that runs every 5 minutes as www-data.
- After a few minutes check in the admin settings that the time updated.
Typical scenario
A small instance is used almost entirely through the desktop client and WebDAV, and hardly anyone logs in through the browser. The basic settings show the background job mode as 'AJAX', and the warning 'Last background job execution ran 3 days ago' appears. In AJAX mode, jobs run only on browser page loads. First check with crontab -u www-data -l or systemctl list-timers whether a real cron or timer entry exists.
FAQ
Why not AJAX?
AJAX only runs jobs when someone uses the web UI, and only one per page load. With little usage jobs pile up.
Can cron.php run as root?
No. cron.php must run as the owner of the Nextcloud files, otherwise it creates files with wrong permissions and Nextcloud aborts.
Which mode is recommended?
Cron, every five minutes via the operating system. It runs independently of user activity and spreads the load evenly. AJAX is only suitable for testing, and Webcron for environments without access to the system cron, such as simple web hosting.
What stops working when jobs do not run?
Cleanup of trash and file versions, refreshing of file indexes and notifications, syncing of groups or LDAP users, and the tasks of some apps are not carried out. Storage slowly fills up and notices arrive late.
Why must cron run as the web server user?
The job writes to files and cache owned by the web server user. If it runs as root, files with the wrong owner appear and later web server access fails. So create the entry in the crontab of www-data, or use User= in the systemd unit.