Nextcloud 15 php fails cron job with error

Hi All,
Just trying to figure everything out after the initial setup has finished.
I used the web installer to a fresh debian 9 install on a vm

Trying to run background jobs as cron and its not working.
I don’t believe the issue I’m having is permissions.
I also don’t believe everyone is using AJAX for maintenance.
If tried running the script as a service as well but no joy. Fails to complete task
I have already configured php.ini as per documentation recommendations

Syslog error:
Feb 7 12:19:30 debian systemd[1]: Started Nextcloud cron.php job.
Feb 7 12:19:30 debian php7.0[2418]: PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 36864 bytes) in /var/www/html/3rdparty/composer/autoload_static.php on line 2439
Feb 7 12:19:30 debian systemd[1]: nextcloudcron.service: Main process exited, code=exited, status=255/n/a
Feb 7 12:19:30 debian systemd[1]: nextcloudcron.service: Unit entered failed state.
Feb 7 12:19:30 debian systemd[1]: nextcloudcron.service: Failed with result ‘exit-code’.

The line causing the issue in that file is:
‘Symfony\Component\Translation\Loader\QtFileLoader’ => DIR . ‘/…’ . ‘/symfony/translation/Loader/QtFileLoader.php’,

[PHP Modules]
apc
apcu
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imagick
imap
intl
json
ldap
libsmbclient
libxml
mbstring
memcache
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
smbclient
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Any help would be appreciated
If i need more logs let me know and I’ll edit the post.

Regards,
Kyser

Check memory_limit in /etc/php/7.0/cli/php.ini. By (Debian’s?) default it’s set to -1, which means unlimited.

Could you post the output of sudo crontab -u www-data -l?

cat /etc/php/7.0/cli/php.ini | grep memory_limit
memory_limit=512

I followed the tutorial online and when i got the error i bumped it up to 512

sudo crontab -u www-data -l
'# Edit this file to introduce tasks to be run by cron.
'#
'# Each task to run has to be defined through a single line
'# indicating with different fields when the task will be run
'# and what command to run for the task
'#
'# To define the time you can provide concrete values for
'# minute (m), hour (h), day of month (dom), month (mon),
'# and day of week (dow) or use ‘*’ in these fields (for ‘any’).#
'# Notice that tasks will be started based on the cron’s system
'# daemon’s notion of time and timezones.
'#
'# Output of the crontab jobs (including errors) is sent through
'# email to the user the crontab file belongs to (unless redirected).
'#
'# For example, you can run a backup of all your user accounts
'# at 5 a.m every week with:
'# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
'#
'# For more information see the manual pages of crontab(5) and cron(8)
'#
'# m h dom mon dow command
*/15 * * * * php -f /var/www/html/cron.php

sudo cat /var/log/syslog
Feb 7 21:20:01 debian cron[479]: (www-data) RELOAD (crontabs/www-data)
Feb 7 21:20:01 debian CRON[5571]: (www-data) CMD (php -f /var/www/html/cron.php)
Feb 7 21:20:01 debian CRON[5570]: (CRON) info (No MTA installed, discarding output)

edit: i installed postfix its logging the output under the www-data user (I have cron setup correctly)
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 36864 bytes) in /var/www/html/3rdparty/composer/autoload_static.php on line 2439

Put the paste within ``` at the beginning and end, that way it makes a code-block and makes it a bit better readable.

What’s the output of php --ini (first three lines is enough)?

why not have the whole lot :wink:
Edit: Fixed
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
/etc/php/7.0/cli/conf.d/20-apcu.ini,
/etc/php/7.0/cli/conf.d/20-apcu_bc.ini,
/etc/php/7.0/cli/conf.d/20-bz2.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-curl.ini,
/etc/php/7.0/cli/conf.d/20-dom.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-igbinary.ini,
/etc/php/7.0/cli/conf.d/20-imagick.ini,
/etc/php/7.0/cli/conf.d/20-imap.ini,
/etc/php/7.0/cli/conf.d/20-interbase.ini,
/etc/php/7.0/cli/conf.d/20-intl.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-ldap.ini,
/etc/php/7.0/cli/conf.d/20-mbstring.ini,
/etc/php/7.0/cli/conf.d/20-memcache.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_firebird.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-redis.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-simplexml.ini,
/etc/php/7.0/cli/conf.d/20-smbclient.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini,
/etc/php/7.0/cli/conf.d/20-wddx.ini,
/etc/php/7.0/cli/conf.d/20-xmlreader.ini,
/etc/php/7.0/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.0/cli/conf.d/20-xsl.ini,
/etc/php/7.0/cli/conf.d/20-zip.ini

Because all those aren’t relevant and now it’s missing the important part.

Any Ideas?

How about php -i|grep memory_limit ?

After rereading this thread I wonder if you have both systemd and cron enabled for this job. You should go with either one of those.

Also, what happens if you invoke php -f /var/www/html/cron.php from the shell as root?

php -i | grep memory_limit
memory_limit => 512 => 512
( I had bumped this up from the recommended 256M)
I was using cron when I found it was failing I removed the cron job for cron.php and moved it to a systemd process and as per request for cron output i removed the systemd event and added the cronjob back in to post results I didn’t run both at the same time.

sudo php -f /var/www/html/cron.php
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 36864 bytes) in /var/www/html/3rdparty/composer/autoload_static.php on line 2439

sudo su
'# php -f /var/www/html/cron.php
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 36864 bytes) in /var/www/html/3rdparty/composer/autoload_static.php on line 2439

I have since removed all 3rd party plugins and the issue remains
Edit: for legibility

Looks like i have managed to resolve the issue on my own
I updated to current ( 15.0.4)
gave rwx permissions to www-data
chowned /html folder to www-data
removed all php modules and purged them
installed recommended modules from here:
https://docs.nextcloud.com/server/15/admin_manual/installation/source_installation.html

restarted apache
now the memory issue has gone and also the occ is working

So the important part to take from this is be minimal with your installation don’t get exited and add in too many things