Cant switch Background jobs from Ajax to Cron!

Hello dear friends!

Im a bit of a noob here so apologies if the question is stupid but… when I try to switch to Cron in the web interface of nextcloud, the web interface shows me that the change was made, my password is not asked from me by the system, then, when I refresh the page, the selection is back to AJAX and I dont seem to be able to move from AJAX to cron. I setup the cron tab to excecute each 5 minutes. In a previous installation following this tutorial → How to Install and Configure Nextcloud Hub 21 - Tech Guides.

I dont seem to be able to find any info about this online :frowning: is it my error? Why is this happening!? How can i fix it!!?!

Thanks a lot in advanced!!

Hello @leop,

this is indeed a bug in NC24, see [stable24] Fix backgroundjobs mode by kesselb · Pull Request #32470 · nextcloud/server · GitHub for details. Should be fixed in the next version I guess (24.0.2).
You can try to change it via occ, see https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/occ_command.html#background-jobs-selector

Thank you very much for that answer… if possible, ((sorry for my noobness)) could you please walk me trhogugh a bit more on what I need to do!?

I have tried the command

sudo -u www-data php occ background:Cron

In response i got “Could not open input file: occ”

Any ideas?

Thank you very much!

That depends on how you installed nextcloud (like operating system, docker container, etc.).

Generally you need to be in the nextcloud directory, so /var/www/nextcloud/ for example. Change the directory cd /var/www/nextcloud/ and then execute the command above (see https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/occ_command.html#using-the-occ-command)
Depending on your knowledge I strongly suggest to get to know some basics before messing with the commandline.

Thanks a lot once again. Im in a system that its intended for me to learn! Its been really great to learn linux hands on and thanks to people like you this chapter of human history becomes available to many noobs like me. Im super gratefully really.

About the installation, Its running on Ubuntu 20.4 and I did it Following this tutorial → https://techguides.yt/guides/how-to-install-and-configure-nextcloud-hub-21/ … If I understood correctly, they call this “the old fashioned way” of installing it, I didnt used Snap, just made it all in the command line.

I have what you said from the nextcloud directory. I got the following message! If possible, could you hint me towards where I could go to sort this one out?

Blockquote
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:139
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(261): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(411): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(176): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(367): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(983): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(713): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(184): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1105): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(2082): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(122): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(454): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1445): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(602): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1104): OC::init()
#38 /var/www/nextcloud/console.php(48): require_once(‘…’)
#39 /var/www/nextcloud/occ(11): require_once(‘…’)

That’s your main problem here, no driver is found to connect to the database. Judging from the installation guide you linked, you’re using mysql.
I’m not familiar with this error (although I’ve seen it a couple of times here in the forum, so a search might help), but can you check, which php version you’re running?

So use php -v and look at the output.

The guide installed php 8, but it might be possible that you also have 8.1 or the like installed, where the mysql driver is missing.

Another thing would be ls /usr/bin/php* to look up if there’re multiple php binaries. If it is the case, try using php8.0 instead of just php

Thanks! Ill have a look at this tomorrow! Gotta go to sleep for now!

Best health, forces and inspiration to you and your loved ones.

I’m running nextcloud in a docker container, and this worked for me:

docker exec -it -u 33 nextcloud_app_1 php occ background:Cron

Hello

I’ve ran into your exact error recently atfer trying to run occ commands. The Solution is easy.

In your Nextcloud, check what Version you’re running for PHP (Settings → System)

PHP

Version: 8.0.20
This is the PHP Version you want to use to execute the Command. Other installed Version do not work. Usually if you just type “php”, it will refer to the newest version present in your System.
This is a typical case of “Know your System and Tools”

You have to use the www-data User (Or whatever your webserver-user is, www-data is default most of the times). Also make sure to use sudo. Next you’re going to add the direct path to your php version (Under /usr/bin/version/ and the direct path to your nextcloud occ directory. Your Command should look like this now:

sudo -u www-data /usr/bin/php8.0 /var/www/nextcloud/occ xyz

Noticed the xyz? That is where you’ll place your occ command that you want to execute, for example
background:Cron

Happy to assist with further Questions