# Cronjob is not working by an issue with php

**URL:** <https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071>\
**Category:** ℹ️ Support\
**Tags:** cron, hosting\
**Created:** [January 14, 2019, 9:34am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071 "2019-01-14T09:34:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [January 14, 2019, 9:34am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/1 "2019-01-14T09:34:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![eehmke](https://help.nextcloud.com/user_avatar/help.nextcloud.com/eehmke/32/8934_2.png) [@eehmke](https://help.nextcloud.com/u/eehmke)\
**Post date:** [January 15, 2019, 10:12am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/2 "2019-01-15T10:12:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [January 21, 2019, 6:53am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/3 "2019-01-21T06:53:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [January 21, 2019, 9:35am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/4 "2019-01-21T09:35:13Z")

</div>

> [@boeset](#):
>
> I have to call the script explicitly with php7.1 - I don’t if this is a critical point.

Depends on your NC Version. E.g. 15 does not support php below version 7 - [Installation on Linux — Nextcloud 15 Administration Manual 15 documentation](https://docs.nextcloud.com/server/15/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation), but NC 13 supports php Version 5.6 - [Installation on Linux — Nextcloud 13 Administration Manual 13 documentation](https://docs.nextcloud.com/server/13/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation). In Any way it is higher than 4.4.9.

---

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [January 21, 2019, 10:57am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/5 "2019-01-21T10:57:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![gas85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gas85/32/7772_2.png) [@gas85](https://help.nextcloud.com/u/gas85)\
**Post date:** [January 21, 2019, 1:21pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/6 "2019-01-21T13:21:17Z")

</div>

> [@boeset](#):
>
> Can I force the cronjobs to use a specific php version?

```
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`

---

<div class="post-metadata">

**Author:** ![eehmke](https://help.nextcloud.com/user_avatar/help.nextcloud.com/eehmke/32/8934_2.png) [@eehmke](https://help.nextcloud.com/u/eehmke)\
**Post date:** [January 22, 2019, 12:04pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/7 "2019-01-22T12:04:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [January 24, 2019, 1:31pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/8 "2019-01-24T13:31:10Z")

</div>

> [@eehmke](#):
>
> sudo -u www-data php7.1 -f ~/svn/cloud/cron.php

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

---

<div class="post-metadata">

**Author:** ![CFelix](https://help.nextcloud.com/letter_avatar/cfelix/32/5_5575768a8748004e209b776fc1b2916d.png) [@CFelix](https://help.nextcloud.com/u/CFelix)\
**Post date:** [January 24, 2019, 1:35pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/9 "2019-01-24T13:35:22Z")

</div>

Login as `root` and execute the following command:

`apt-get install sudo`

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

---

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [January 24, 2019, 1:35pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/10 "2019-01-24T13:35:59Z")

</div>

> [@gas85](#):
>
> Try to set instead of php full path like: `/usr/bin/php7.0`

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**  
'

---

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [January 24, 2019, 1:39pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/11 "2019-01-24T13:39:29Z")

</div>

> [@CFelix](#):
>
> Login as `root` and execute the following command:

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

---

<div class="post-metadata">

**Author:** ![CFelix](https://help.nextcloud.com/letter_avatar/cfelix/32/5_5575768a8748004e209b776fc1b2916d.png) [@CFelix](https://help.nextcloud.com/u/CFelix)\
**Post date:** [January 24, 2019, 1:51pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/12 "2019-01-24T13:51:32Z")

</div>

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"`

---

<div class="post-metadata">

**Author:** ![boeset](https://help.nextcloud.com/letter_avatar/boeset/32/5_5575768a8748004e209b776fc1b2916d.png) [@boeset](https://help.nextcloud.com/u/boeset)\
**Post date:** [February 6, 2019, 7:36am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/13 "2019-02-06T07:36:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kriszy](https://help.nextcloud.com/letter_avatar/kriszy/32/5_5575768a8748004e209b776fc1b2916d.png) [@kriszy](https://help.nextcloud.com/u/kriszy)\
**Post date:** [June 16, 2020, 11:47am UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/14 "2020-06-16T11:47:37Z")

</div>

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](https://www.ionos.de/hilfe/hosting/php-fuer-web-projekt-verwenden/php-dateien-mittels-php-cli-in-der-kommandozeile-shell-ausfuehren/).

---

<div class="post-metadata">

**Author:** ![Witzker](https://help.nextcloud.com/user_avatar/help.nextcloud.com/witzker/32/36775_2.png) [@Witzker](https://help.nextcloud.com/u/Witzker)\
**Post date:** [April 16, 2021, 11:22pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/15 "2021-04-16T23:22:27Z")

</div>

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 - 🗃 Hosting providers - Nextcloud community](https://help.nextcloud.com/t/setup-crone-jobs-correctly-in-nextcloud-21-0-1-on-ionos-webspace/113316)  
THX

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [September 23, 2024, 4:29pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/16 "2024-09-23T16:29:34Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 9, 2024, 4:45pm UTC](https://help.nextcloud.com/t/cronjob-is-not-working-by-an-issue-with-php/45071/17 "2024-12-09T16:45:40Z")

</div>


