Cronjob is not working by an issue with php

Hi,

my cronjob in nextcloud is not working. By starting it directly over the prompt i got:

php7.1 -f ~/svn/cloud/cron.php


Fatal error: Uncaught Error: Call to a member function getLogger() on null in /homepages/11/d65873472/htdocs/svn/cloud/cron.php:160
Stack trace:
#0 {main}
thrown in /homepages/11/d65873472/htdocs/svn/cloud/cron.php on line 160

What is the reason/origin?
The installation is hostet at 1&1 as webspace
Do you need mor informations?

Thanks for your help!

Regards

Do you have this declarations in your config.php?

‘logfile’ => ‘<path to your data directory>/nextcloud.log’,
‘loglevel’ => 2,

The line 160 in the cron.php is already an exception, so something else is broken too. Did you start the cronjob by the user that owns the directory? What system is this running on? The path /homepages looks strange.

Hi,

the system runs under
SMP Debian 3.16.59-1~ui80+1 (2018-10-03) x86_64.
Yes I started the cronjob as the same user - I have no other choice.
Since my nexcloud runs at a webhoster contract, the side is hosted together with other under this path ‘homepages/…’

My home directory is located deeper int the tree.
/homepages/11/d65873472/htdocs.

The systems php version is
php --version PHP 4.4.9 (cgi-fcgi) (built: Nov 7 2018 13:27:00)

I have to call the script explicitly with php7.1 - I don’t if this is a critical point.
I set the loglevel to two, but i dont’t see the log file at the specified path.

Depends on your NC Version. E.g. 15 does not support php below version 7 - Installation on Linux — Nextcloud 15 Administration Manual 15 documentation, but NC 13 supports php Version 5.6 - Installation on Linux — Nextcloud 13 Administration Manual 13 documentation. In Any way it is higher than 4.4.9.

The cronjobs didn’t run under a former Version of nc, so I try to figure out why.
But there is one importatnt point: At the mamagement site of my hoster I can define that the domain for nextcloud uses php7.x. But when I access my sites via ssh, there is php 4.4.9 set as default. The question is which on is used by the cron jobs.
Can I force the cronjobs to use a specific php version? I know that I did it by php7.1 cron.php but how are other script called from the cron.php?

whereis php #shows you where PHP is located
php: /usr/bin/php7.0 /usr/bin/php...

Try to set instead of php full path like: /usr/bin/php7.0

The cron job must run as the same user as the webserver, that would be www-data on a debian system. To call the command manually, use

sudo -u www-data php7.1 -f ~/svn/cloud/cron.php

To setup the cron job, use

sudo crontab -u www-data -e

Did you do that?

There is no sudo avaiable:
sudo -u www-data php7.1 -f ~/svn/cloud/cron.php
-bash: sudo: command not found

Login as root and execute the following command:

apt-get install sudo

This should fix the -bash: sudo: command not found error message.

Yes I tried, but unfortunately it leads to the same result:

’ $ /usr/bin/php7.1 ~/svn/cloud/cron.php
X-Powered-By: PHP/7.1.25
Content-type: text/html; charset=UTF-8


Fatal error: Uncaught Error: Call to a member function getLogger() on null in /homepages/11/d65873472/htdocs/svn/cloud/cron.php:160 Stack trace: #0 {main} thrown in /homepages/11/d65873472/htdocs/svn/cloud/cron.php on line 160
'

I have just user permissions and just a few basic tools, the hoster has limitied the available command line tools.

In that case it may be possible that sudo is installed but you may not use it due to being restricted.

Please try the following:

su - www-data -c "/usr/bin/php7.1 -f ~/svn/cloud/cron.php"

1 Like

I can enter the command without getting an error message but it has no effect. In the Settings in the nc web Interface is shown that the cron Job was not done.
As Workaround I activated the cronjob via AJAX.

I have the same problem at my installation with Nextcloud v19.0, which is also hosted at 1&1 / IONOS. The solution is to use the php command line interpreter. You have to run it with the following command:
/usr/bin/php7.4-cli -f ~/svn/cloud/cron.php

A german description to use the PHP Command Line Interpreter is to find at the IONOS Help Center.

1 Like

Hi kriszy
I’m on ionos too but do not understand setting the crone jobs correctly

Maybe you can help me her:
Setup Crone jobs correctly in Nextcloud 21.0.1 on IONOS webspace - :card_file_box: Hosting providers - Nextcloud community
THX