Nextcloud Part 4 - Cron
Nextcloud needs to be able to execute tasks in the background. It can do this just by executing those tasks whenever any page is loaded via AJAX or webcron, but this will only scale so far. Also, the News app specifically warns that RSS feeds will not be updated in a timely fashion unless cron mode is used.
Usually cron mode means creating a cron entry using the crontab command on the host operating system to execute cron.php as the www-data user. Running Nextcloud under Docker makes this even easier by providing a /cron.sh command in the Docker image which can also be executed by a crontab entry.
However, RKE makes this even easier through the use of a sidecar:
- On the nextcloud-fpm workload, click add a sidecar
- Use the same image used for nextcloud-fpm
- Mount the same persistent volume as /var/www/html
- Use /cron.sh as the command
Once it deploys there will be two containers running - one for the main workload and one for the sidecar. Looking at the logs of the running sidecar, it will look like this:
crond: file www-data: crond: line php -f /var/www/html/cron.php crond: wakeup dt=60 crond: file www-data: crond: line php -f /var/www/html/cron.php crond: wakeup dt=60 crond: file www-data: crond: line php -f /var/www/html/cron.php
It will take up every minute or so to see if there are any tasks to be executed. The status of the background jobs can be checked on the Basic Settings panel to see when the last job was successfully executed.