I have recently and successfully switched my Nextcloud setup to a Docker container, using the cron-enabled variant from the official examples.
All works well – except the cron jobs.
When I execute
cron.php from the command line inside the Docker container, I don’t get to see any output for several minutes and finally:
www-data@74cdad749be7:~/html$ php -f cron.php
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 9736736 bytes) in /var/www/html/lib/private/Files/Storage/Local.php on line 218
How to fix this?
Under Settings > Basic settings, are you set to use cron or webcron? I think it should be cron if you’re using the Dockerfile to build the image with cron support, but you appear to be manually invoking webcron above.
It’s set to cron.
This is my crontab:
www-data@74cdad749be7:~/html$ cat /etc/crontab
# m h dom mon dow user command
*/5 * * * * www-data php -f /var/www/html/cron.php
* */12 * * * www-data php -f /var/www/html/occ app:update
15 */4 * * * www-data php -f /var/www/html/occ preview:pre-generate
When I realized that Nextcloud complained about the cronjob having been last run a long time ago (before I switched to the Docker container), I issued the command in the terminal to see what’s going on, and then I saw this error. That’s why I was manually invoking the cron job
cron.php appears to be the correct script to execute, regardless of the choice of cron/webcron:
Those 536870912 bytes that are allowed equal 512 MiB exactly. I actually fixed the issue for now by increasing PHP’s memory limit to 2 GiB:
sed -i 's/memory_limit=512M/memory_limit=2048M/' /usr/local/etc/php/conf.d/memory-limit.ini
(Was inspired to do this by this Github issue about a similar issue when running
… but now I have to change the Dockerfile so that this is done automatically during rebuilds, and I’m left wondering why my
cron.php has such a hunger for memory, while it seems to be okay for every one else to have th default limit of 512 MiB…
Thanks for your help!