Note

Selecting the option Cron in the admin menu for background jobs is not mandatory, because once cron.php is executed from the command line or cron service it will set it automatically to Cron.

With crontab:
crontab -u www-data -e
*/5  *  *  *  * php -f /var/www/nextcloud/cron.php
With systemd:
nano /etc/systemd/system/nextcloudcron.service
[Unit]
Description=Nextcloud cron.php job
 
[Service]
User=www-data
ExecCondition=php -f /var/www/nextcloud/occ status -e
ExecStart=/usr/bin/php -f /var/www/nextcloud/cron.php
KillMode=process
nano /etc/systemd/system/nextcloudcron.timer
[Unit]
Description=Run Nextcloud cron.php every 5 minutes
 
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Unit=nextcloudcron.service
 
[Install]
WantedBy=timers.target
systemctl enable --now nextcloudcron.timer

Cron job not working:
nano /etc/php/8.2/mods-available/apcu.ini
apc.enable_cli=1

If it still doesn’t work:

sudo -u www-data php8.0 --define apc.enable_cli=1  /var/www/nextcloud/occ  maintenance:repair

https://help.nextcloud.com/t/oc-memcache-apcu-not-available-for-local-cache-issue-upon-initial-setup/140117 https://help.nextcloud.com/t/occ-wont-run-with-memcache-apcu/119724/7