Failed to connect to the database cron background jobs

Hi, I am unable to turn the cron nextcloud optimizer.

Nextcloud version (eg, 12.0.2): 13
Operating system and version (eg, Ubuntu 17.04): Debian 9
Apache or nginx version (eg, Apache 2.4.25): Nginx 1.10.3
PHP version (eg, 7.1): php 7.0

The issue you are facing:
I want run the background jobs using cron but I get some weird output.

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

Steps to replicate it:

  1. cd nextcloud
  2. sudo -u www-data php cron.php

I get

PHP Fatal error:  Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /home/www/nextcloud/lib/private/DB/Connection.php:64                          
Stack trace:                                                                                                                                                                                                                      
#0 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()                                                                                                                  
#1 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()                                                                                       
#2 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()                                                                                           
#3 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()                                                                                              
#4 /home/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)                                                                                                                   
#5 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOPgSql\Driver), Object(Doctrine\DBAL\Co in /home/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 /home/www/nextcloud/lib/private/DB/Connection.php:64                          
Stack trace:                                                                                                                                                                                                                      
#0 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()                                                                                                                  
#1 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()                                                                                       
#2 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()                                                                                           
#3 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()                                                                                              
#4 /home/www/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)                                                                                                                   
#5 /home/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOPgSql\Driver), Object(Doctrine\DBAL\Co in /home/www/nextcloud/lib/private/DB/Connection.php on line 64

The output of your Nextcloud log in Admin > Logging:

Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'UPDATE "oc_filecache" SET "mtime" = GREATEST("mtime", ?), "etag" = ? WHERE ("storage" = ?) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '2e4ba8d4baea95b8b21ff7bfcc882adc', '09cf15e81a736abb5656773b1dea27a2', '695364b1e6a69880097a408aeef9b843'))' with params [1538673645, "5bb64bedb446b", 1]: SQLSTATE[40P01]: Deadlock detected: 7 ERROR: deadlock detected DETAIL: Process 9585 waits for ShareLock on transaction 8332515; blocked by process 9593. Process 9593 waits for ShareLock on transaction 8332509; blocked by process 9585. HINT: See server log for query details. CONTEXT: while rechecking updated tuple (4,49) in relation "oc_filecache"

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

just installed this install, so this shouldnt be needed