Background jobs not working

Nextcloud version 25.0.1
Operating system and version _Raspbian
Apache 2.4.54
PHP version 8.0 and 8.1

The issue I am facing:
Background jobs not working (is this linked to “No memory cache has been configured” issue ?)
When choosing Ajax, system says “Some jobs have not been executed since 15 days ago. Please consider increasing the execution frequency.”
When choosing Cron, “Last job execution ran xx hours ago. Something seems wrong.”

The output of logging every 15 mins when trying to run cron.php

[cron] Error: Error: Call to undefined function simplexml_load_file() at <<closure>>

0. /var/www/nextcloud/lib/private/App/AppManager.php line 507
   OC\App\InfoParser->parse()
1. /var/www/nextcloud/lib/private/legacy/OC_App.php line 596
   OC\App\AppManager->getAppInfo()
2. /var/www/nextcloud/lib/private/AppFramework/App.php line 74
   OC_App::getAppInfo()
3. /var/www/nextcloud/lib/private/legacy/OC_App.php line 281
   OC\AppFramework\App::buildAppNamespace()
4. /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php line 117
   OC_App::registerAutoloading()
5. /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php line 91
   OC\AppFramework\Bootstrap\Coordinator->registerApps()
6. /var/www/nextcloud/lib/base.php line 671
   OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
7. /var/www/nextcloud/lib/base.php line 1144
   OC::init()
8. /var/www/nextcloud/cron.php line 43
   require_once("/var/www/nextcloud/lib/base.php")

at 2022-11-09T22:30:02+00:00

My config.php file:

  GNU nano 5.4                       config.php                                 
<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxx',
  'passwordsalt' => 'xxxxxxxx',
  'secret' => 'xxxxxxxx',
  'trusted_domains' => 
  array (
    0 => '192.168.xxxxxxx',
    1 => 'xxxxxxxx',
  ),
  'datadirectory' => '/mnt/xxxxxxx/data',
  'dbtype' => 'mysql',
  'version' => '25.0.1.1',
  'overwrite.cli.url' => 'http://192.168.xxxxxxx/nextcloud',
  'dbname' => 'xxxxxxxx',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxxxxxxxx',
  'dbpassword' => 'xxxxxxxxx',
  'installed' => true,
  'default_phone_region' => 'GB',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'xxxxxxx',
  'mail_domain' => 'xxxxxxx',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.xxxxxxx',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'xxxxxxxxx',
  'mail_smtppassword' => 'xxxxxxxx',
  'maintenance' => false,
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'updater.secret' => '$2y$10$jUU8DVxxxxxxZGj>
  'theme' => '',
  'loglevel' => 2,
);

No, should not be. You do need to configure a memory cache btw.

Ajax relies on page loads and really isn’t a good method.

Do you have any cron configured to run it?

Thank you KarlF12,

Regarding cron,
I added this line to crontab with user www-data:
*/5 * * * * php -f /var/www/nextcloud/cron.php

Regarding Memory Cache, when I add the following line to /var/www/nextcloud/config/config.php:
‘memcache.local’ => ‘\OC\Memcache\APCu’, I can no longer access Nexcloud.

Try including the full path to php in the crontab.

You can tell if it works because the setting will automatically change from Ajax to cron.

Thank you very much.
Not sure whether this changes anything, but just for info, I have 2 php folders, php 8.0 and php 8.1. Not sure why and how that happened.
When I check in NextCloud’s system page, it shows that it uses php 8.0
When I check Rapsbian, it says that it uses php 8.1.
That is also bothering me as apcu is only present in php 8.1

I’ve included the full path to php, trying all 4 options one after the other:
*/5 * * * * /usr/bin/php8.0 -f /var/www/nextcloud/cron.php
*/5 * * * * /usr/bin/php8.1 -f /var/www/nextcloud/cron.php
*/5 * * * * /usr/bin/php8.0-cli -f /var/www/nextcloud/cron.php
*/5 * * * * /usr/bin/php8.1-cli -f /var/www/nextcloud/cron.php

None fo them seemed to work, the setting did not change from Ajax to Cron.

Okay, so… two things I would try just to test.

First can you change to the www-data user and then run the php manually? If it works then the option In the settings will flip over to cron. This will verify that what you’re trying to run in cron is correct. I would then change it back over to ajax for now so it can still run some background jobs in the meantime.

Second I would test your cron by having it touch a file just to see that it’s running. Make sure it’s in a folder that www-data can access. For example:

*/5 * * * * /usr/bin/touch /mnt/xxxxxxx/data/cron-test-delete-me

Should create the empty file owned by www-data and update the file timestamp every 5 minutes.

I’ve run sudo -u www-data php cron.php and got the following error message:

Error: Call to undefined function simplexml_load_file() in /var/www/nextcloud/lib/private/App/InfoParser.php:69

Stack trace:

#0 /var/www/nextcloud/lib/private/App/AppManager.php(507): OC\App\InfoParser->parse()

#1 /var/www/nextcloud/lib/private/legacy/OC_App.php(596): OC\App\AppManager->getAppInfo()

#2 /var/www/nextcloud/lib/private/AppFramework/App.php(74): OC_App::getAppInfo()

#3 /var/www/nextcloud/lib/private/legacy/OC_App.php(281): OC\AppFramework\App::buildAppNamespace()

#4 /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(117): OC_App::registerAutoloading()

#5 /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(91): OC\AppFramework\Bootstrap\Coordinator->registerApps()

#6 /var/www/nextcloud/lib/base.php(671): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()

#7 /var/www/nextcloud/lib/base.php(1144): OC::init()

#8 /var/www/nextcloud/cron.php(43): require_once(‘…’)

#9 {main}

Ideally the same way you would run it from cron. Maybe something like this: sudo -u www-data /usr/bin/php -f /var/www/nextcloud/cron.php

I think I got cron working, using:
sudo -u www-data /usr/bin/php8.0 -f /var/www/nextcloud/cron.php

Thank you very much for your patience.
No remains the Memory cache issue.

Okay so here is the explanation of the cache warning: https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/security_setup_warnings.html#cache-warnings

And the cache setup documentation: https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/caching_configuration.html

You don’t strictly have to set it up, but it works much better with memory caching. I don’t know the exact steps for Raspbian, but speaking generally, you probably want to use APCu for local caching and Redis for distributed caching and file locking.

Thank you KarlF12, I’ve read the docs and started working on this.

I believe my first step should be to add the line:
‘memcache.local’ => ‘\OC\Memcache\APCu’,
to my /var/www/nextcloud/config/config.php
When I do that, Nextcloud’s admin pages become unavailable and a error message is displayed.

Since my Raspbian is a CLI version, I see that I should set the apc.enable_cli to 1 on my php.ini config file. To find the correct php.ini, I’ve run:
php -i |grep “php.ini”
The came back with:
Loaded Configuration File => /etc/php/8.1/cli/php.ini

I’ve added the line to this file, restarted apache2, but again Nextcloud’s admin pages become unavailable and the same error message appears:
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
I check the server log and found this line:
[Sun Nov 13 12:20:32.474981 2022] [php:error] [pid 13137] [client xxxxxxxxxxxxxx] PHP Fatal error: Uncaught OCP\HintException: [0]: Memcache \OC\Memcache\APCu not availabl>o

So APCu doesn’t seem to be available according to this error log.
Looking for that, I find an instance of APCu in /etc/php/8.1/mods-available, but not in /etc/php/8.0/mods-available.

That is as far as I can get.

Do you actually have the APCu packages installed?

I installed apcu with the following command (following the documentation):
sudo apt install php-apcu

I just re-run it to make sure it is installed, and the output was:
php-apcu is already the newest version (5.1.21+4.0.11-8+0~20220625.32+debian11~1.gbpa7cde5).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

I hope this answers your question, and if it doesn’t please accept my apologies, I’m not an expert in these matters.
I’ve been running Nextcloud as a single user for several years and am very happy with it, managing the system myself with 95% of the info I need found online. But here it looks like I need additional help. Thank you.

1 Like

It’s probably because of this right here. Having two versions of PHP in play is probably causing confusion. Is there a reason to have two versions installed?

I’m afraid there’s no reason, I just noticed this the other day.
I had a feeling that this was causing trouble, but I’m not sure how to get rid of one of them.
As I said in an earlier post, when I check in NextCloud’s system page, it shows that it uses php 8.0, and when I check Rapsbian, it says that it uses php 8.1
I guess I should tell nextclpoud to use php8.1 as well, and then delete php8.0 ?

I can’t really tell you how to resolve it without knowing how it got that way. I hesitate to say just uninstall it because I don’t know anything else about the system in question.

If one of them was installed at a specific version instead of a meta package, you can find it with dpkg --get-selections | grep php

If one was installed from source or some other way, then it’s hard to say.

$ dpkg --get-selections | grep php
libapache2-mod-php8.0 install
php-apcu install
php-common install
php-mysql install
php-smbclient install
php8.0 install
php8.0-bcmath install
php8.0-bz2 install
php8.0-cli install
php8.0-common install
php8.0-curl install
php8.0-gd install
php8.0-gmp install
php8.0-imagick install
php8.0-imap install
php8.0-intl install
php8.0-mbstring install
php8.0-mysql install
php8.0-opcache install
php8.0-readline install
php8.0-sqlite3 install
php8.0-xml install
php8.0-zip install
php8.1-apcu install
php8.1-cli install
php8.1-common install
php8.1-mysql install
php8.1-opcache install
php8.1-phpdbg install
php8.1-readline install
php8.1-smbclient install

My system is fairly straight forward. I just re-installed it from scratch 3 weeks ago after the update to nexcloud Hub 3 crashed my system, and also I wanted to update to 64 bits.
I’m a single user, Nextcloud syncs my calendar and address book, and provides me with a cloud.

  • I install raspbian and configure ssh with key
  • I mount a usb drive, setup gmail, install noip, letsencrypt, samba
  • I install Nextcloud

That’s pretty much it.
After that it’s a case of updating and maintaining all this.

But I try to recap my install.
First I installed Raspbian and Samba, and maybe php8.1 was installed at that point.
After that, I followed these instructions to instal NextCloud:
https://pimylifeup.com/raspberry-pi-nextcloud-server/
And it asks to install php8.0

That could be a possible explanation of the current situation.
If that is the case, could I switch Nextcloud to php8.1, and then delete php8.0 ?

PHP 8.1 is what’s recommended in the documentation. Make sure you have all the proper modules installed.