This is what fixed it for me, the -d memory_limit=-1
me@server:/var/www/nextcloud$ sudo -u www-data php -d memory_limit=512M ./cron.php
or actually what I was initially after …
me@server:/var/www/nextcloud$ sudo -u www-data php -d memory_limit=-1 ./occ db:add-missing-indices
A very frustrating experience. Now to deal with the “A background job is pending that checks for user imported SSL certificates” problem