Can't get cron to run Background Jobs

cron will not execute automatically even though I choose cron in settings.

When I manually try to execute cron I get the following output:

jdoe@abcde : ~ $ sudo -u www-data php /var/www/nextcloud/cron.php

PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:64

Stack trace:

#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()

#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()

#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()

#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()

#4 /var/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)

#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configura in /var/www/nextcloud/lib/private/DB/Connection.php on line 64

PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:64

Stack trace:

#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()

#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()

#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()

#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()

#4 /var/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)

#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configura in /var/www/nextcloud/lib/private/DB/Connection.php on line 64

[/details]

Nextcloud version (eg, 12.0.2): Nextcloud 15.0.4
Operating system and version (eg, Ubuntu 17.04): Ubuntu Server 18.04LTS
Apache or nginx version (eg, Apache 2.4.25): nginx version: nginx/1.14.0 (Ubuntu)
PHP version (eg, 7.1): PHP 7.2.15-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:38:01) ( NTS )
Copyright © 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright © 1998-2018 Zend Technologies
with Zend OPcache v7.2.15-1+ubuntu18.04.1+deb.sury.org+1, Copyright © 1999-2018, by Zend Technologies

The issue you are facing: Can’t get cron to run Background Jobs. Only AJAX works. This will not update “News” app.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Choose “cron” in Settings.
  2. Error message " Last job execution ran yesterday. Something seems wrong.

February 24, 2019 at 11:09:45 PM EST
3.

The output of your Nextcloud log in Admin > Logging:

Feb 26 15:31:05 linuxserver php[30259]: PHP Fatal error:  Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:64
Feb 26 15:31:05 linuxserver php[30259]: Stack trace:
Feb 26 15:31:05 linuxserver php[30259]: #0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
Feb 26 15:31:05 linuxserver php[30259]: #1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
Feb 26 15:31:05 linuxserver php[30259]: #2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
Feb 26 15:31:05 linuxserver php[30259]: #3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
Feb 26 15:31:05 linuxserver php[30259]: #4 /var/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
Feb 26 15:31:05 linuxserver php[30259]: #5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configura in /var/www/nextcloud/lib/private/DB/Connection.php on line 64
Feb 26 15:31:05 linuxserver systemd[1]: nextcloudcron.service: Main process exited, code=exited, status=255/n/a
Feb 26 15:31:05 linuxserver systemd[1]: nextcloudcron.service: Failed with result 'exit-code'.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'AN ID',
  'passwordsalt' => 'PASSWORD SALT',
  'secret' => 'A SECRET LIVES HERE',
  'trusted_domains' => 
  array (
    0 => 'files.jdoe.com',
  ),
  'datadirectory' => '/media/DataRAID/nextcloud',
  'dbtype' => 'mysql',
  'version' => '15.0.4.0',
  'overwrite.cli.url' => 'https://files.jdoe.com',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'jDoe',
  'dbpassword' => 'EXAMPLE',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'JDOE',
  'mail_domain' => 'jdoe.com',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'me@me.com',
  'mail_smtppassword' => 'PASSWORD',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
);

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

This seems to be a PHP related problem. The PHP cli program couldn’t find the required mysql database driver. Make sure that it is loaded as for the PHP web access. The loaded modules can be checked by execution php -m on the command line.

Executing php -m and MySQL does not show up. I am using MariaDB. What command would get this going for me?

Thank you very much for your time…

I don’t know your system, but it is essential that you find out how to execute PHP, maybe by providing the full path to the binary?! Additionally you have to configure the PHP CLI correctly, so that the command "php -m" shows the list of available/loaded modules.
To access a MySQL/MariaDB database the mysql drivers need to be loaded, a dedicated mariadb driver doesn’t exist :wink:

I copied the following from my logs. If anyone has any idea how I can resolve please post. Thank you

Mar 6 16:02:31 linuxserver systemd[1]: nextcloudcron.service: Failed with result ‘exit-code’.
Mar 6 16:05:01 linuxserver CRON[11336]: (www-data) CMD (www-data php -f /var/www/nextcloud/cron.php)
Mar 6 16:07:30 linuxserver systemd[1]: Started Nextcloud cron.php job.
Mar 6 16:07:31 linuxserver systemd[1]: nextcloudcron.service: Main process exited, code=exited, status=255/n/a

As far as I remember this question has already been answered in this forum. I would recommend to check if these articles help so solve your problem: https://help.nextcloud.com/search?q=cronjob