Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run backgroud jobs with cronjob #11638

Closed
chaptergy opened this issue Oct 5, 2018 · 5 comments
Closed

Cannot run backgroud jobs with cronjob #11638

chaptergy opened this issue Oct 5, 2018 · 5 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@chaptergy
Copy link

Steps to reproduce

  1. Set "Background Jobs" to cron or webcron
  2. Setup the crontab to * * * * * /usr/bin/php7.1 -f /homepages/32/d672527826/htdocs/nextcloud/cron.php (Every minute for easier debugging)

Expected behaviour

The background jobs should be run

Actual behaviour

The cron.php script has a fatal error

Server configuration

Web server: Shared hosting

Database: mysql 5.5.60

PHP version: 7.2.10

Nextcloud version: 14.0.1.1

Updated from an older Nextcloud/ownCloud or fresh install: Fresh install

Where did you install Nextcloud from: Official webpage installer for shared hosting

Signing status:

Signing status
No errors have been found.

List of activated apps:

App list

All the apps activated by default and no others

Nextcloud configuration:

Config report
$CONFIG = array (
  'instanceid' => '****',
  'passwordsalt' => '****',
  'secret' => '****',
  'trusted_domains' => 
  array (
    0 => '****',
  ),
  'datadirectory' => '/homepages/32/****/htdocs/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '14.0.1.1',
  'overwrite.cli.url' => '****',
  'dbname' => '****',
  'dbhost' => '****',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '****',
  'dbpassword' => '****',
  'installed' => true,
  'mail_domain' => '****',
  'mail_from_address' => 'webmaster',
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => '****',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpport' => '25',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '****',
  'mail_smtppassword' => '****',
);

Are you using external storage, if yes which one: no

Are you using encryption: I'm using hsts?

Are you using an external user-backend, if yes which one: No

Client configuration

Browser: Firefox 62.0.3

Operating system: Windows 10

Logs

Nextcloud log

The nextcloud log stays empty when this issue happens

Cron error message

Failed loading /kunden/homepages/32/****/htdocs/ioncube/ioncube_loader_lin_7.0.so:  /kunden/homepages/32/****/htdocs/ioncube/ioncube_loader_lin_7.0.so: cannot open shared object file: No such file or directory
PHP Warning:  Cannot open '/usr/lib/php7.0/browscap.ini' for reading in Unknown on line 0
<br />
<b>Fatal error</b>:  Uncaught Error: Call to a member function getLogger() on null in /homepages/32/****/htdocs/nextcloud/cron.php:160
Stack trace:
#0 {main}
  thrown in <b>/homepages/32/****/htdocs/nextcloud/cron.php</b> on line <b>160</b><br />
@nextcloud-bot
Copy link
Member

GitMate.io thinks possibly related issues are #10748 (Background jobs fails (cron)), #8759 (Run cleanup of old upload parts in background job), #4179 (Cron jobs not running, and logs filled with "preg_match(): Unknown modifier '/' at..."), #7336 (Error while running background job (Doctrine\DBAL\Exception\DriverException):), and #10658 (Error while running background job (OCP\AutoloadNot AllowedException): Autoload path not allowed).

@soerpoers
Copy link

Exactly the same issue for me. Any idea to solve it?

[23-Oct-2018 20:15:02 UTC] PHP Fatal error: Uncaught Error: Call to a member function getLogger() on null in /home/*/public_html/oecloud/cron.php:160
Stack trace:
#0 {main}
thrown in /home/
/public_html/oecloud/cron.php on line 160

@5p0ng3b0b
Copy link

5p0ng3b0b commented Jan 10, 2019

Does 'cron.php' run OK without errors from the terminal?
cd /path/to/nextcloud
php cron.php

Type which php to obtain the path of the php command that is executed from the terminal. Is it /usr/local/bin/php perhaps?

Try these cron tasks;
* * * * * set > /tmp/vars.txt
* * * * * which php > /tmp/php.txt; php -v >>php.txt

Now from terminal
cat /tmp/vars.txt | grep PATH
and
cat /tmp/php.txt
Is the path to the terminal php command included in the PATH variable of the cron job? Does cron run the same php?
cron jobs do not run /etc/bashrc, /etc/profile, ~/.bashrc or ~/.bash_profile before execution and the cron.php script probably looks for files relative to the current directory when it was executed.

Try;
for C in $(find / -maxdepth 4 -type f -name php 2>/dev/null); do echo $C; $C -v; echo ; done

This lists three different versions of php on my shared host so cron could be calling a different version/build of php to the one used in your terminal or nextcloud site.

0,15,30,45 * * * * cd /path/to/nextcloud; /path/to/terminal/phpcommand/php -f /path/to/nextcloud/cron.php
should be the correct way to run cron.php if it functions as expected when run manually from the terminal after a cd to the nextcloud folder.

Also consider something that does not need to know the nextcloud foldername;
'0,15,30,45 * * * * JOB=$(find ~/ -name -maxdepth 4 cron.php -print -quit); cd $(dirname $JOB); /path/to/working/php -f $JOB
or one cron task for multiple instances of nextcloud on same server.
'0,15,30,45 * * * * for JOB in $(find ~/ -maxdepth 4 -name cron.php | grep -v .trash); do cd $(dirname $JOB); /path/to/working/php -f $JOB; done

Thinking ahead, once your nextcloud instance is using cron correctly, it might be a good idea to remember to remove/disable the task before performing any future upgrades in case it runs during the upgrade. I make a clone of my nextcloud and database to test upgrades nowadays as there is always the possibility of a backup not restoring. It might also be wise to disable any automatic update features in whatever auto installer you used such as softaculous or installatron. Personally I have found installing sfuff fthis way problematic and do not use anymore and they arent usually up-to-date versions. Better to create DB and DB user yourself, wget the latest package and extract from the terminal.

@Poikilos
Copy link

Poikilos commented Apr 16, 2019

I think some people having this error may have a different version of php set for /etc/alternatives than is enabled in apache, but I can't add answers to the following questions due to the site being readonly:

I fixed the error by making sure /etc/alternatives and apache were running the same version of php (this makes sure all the same modules that correctly run nextcloud also are available to /usr/bin/php:

  1. Get your loaded php module version:
sudo apache2ctl -M | grep php
  1. Get your /usr/bin/php version:
/usr/bin/php --version

If they don't match, update-alternatives, replacing X.X with the version found in (2) above:

sudo update-alternatives --set php /usr/bin/phpX.X

(Ubuntu 18.04 Bionic Beaver)

@nix155 @nextcloud-bot Why was #7336 closed without a reason for closing provided? My solution can resolve "PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in ..." in the case that the problem does not lie in Nextcloud like in my case.

OPTIONAL: Change php version for everything (do not do the method below unless you know what you're doing, otherwise change 7.1 in the following back to X.X found above:

ver=7.2
sudo update-alternatives --set php /usr/bin/php$ver
echo "If you use PostgreSQL as your backend, also run:"
echo "sudo apt install php$ver-pgsql"
sudo apt install php$ver-mysql
sudo a2dismod php7.3
sudo a2dismod php7.2
sudo a2dismod php7.1
# AND any other versions you may have enabled,
# or next line will have error saying phpX.X already enabled!
sudo a2enmod php$ver

# next 9 lines are from https://docs.nextcloud.com/server/14/admin_manual/installation/source_installation.html#ubuntu-installation-label
sudo apt install apache2 mariadb-server libapache2-mod-php$ver
sudo apt install php$ver-gd php$ver-json php$ver-mysql php$ver-curl php$ver-mbstring
sudo apt install php$ver-intl php-imagick php$ver-xml php$ver-zip
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo a2enmod ssl


# sudo apt install php$ver-sqlite3
echo "also run: sudo apt -y install php$ver-pgsql # as needed if you use that for Nextcloud"
# sudo apt install php$ver-mysql
# sudo apt install php$ver-pgsql
sudo systemctl restart apache2

@skjnldsv skjnldsv added the 0. Needs triage Pending check for reproducibility or if it fits our roadmap label Jun 12, 2019
@kesselb
Copy link
Contributor

kesselb commented Aug 17, 2019

#13038
#11298

@kesselb kesselb closed this as completed Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

No branches or pull requests

7 participants