Cron Job Issue Need Help

Error description

Cron Jobs wont run

Expected behavior

cron jobs should work fine no error

Installation method

Community Manual installation with Archive

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.50.52"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.3.2",
        "overwrite.cli.url": "http:\/\/192.168.50.52",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 1,
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "default_phone_region": "US",
        "installed": true,
        "maintenance": false,
        "data-fingerprint": "d9406a10eced644733006f377a6be6cf"
    }
}

List of activated Apps

Enabled:
  - activity: 2.20.0
  - calendar: 4.6.6
  - circles: 28.0.0-dev
  - cloud_federation_api: 1.11.0
  - comments: 1.18.0
  - contacts: 5.5.3
  - contactsinteraction: 1.9.0
  - dashboard: 7.8.0
  - dav: 1.29.1
  - federatedfilesharing: 1.18.0
  - federation: 1.18.0
  - files: 2.0.0
  - files_antivirus: 5.4.2
  - files_external: 1.20.0
  - files_pdfviewer: 2.9.0
  - files_reminders: 1.1.0
  - files_sharing: 1.20.0
  - files_trashbin: 1.18.0
  - files_versions: 1.21.0
  - firstrunwizard: 2.17.0
  - logreader: 2.13.0
  - lookup_server_connector: 1.16.0
  - mail: 3.5.7
  - nextcloud_announcements: 1.17.0
  - notes: 4.9.2
  - notifications: 2.16.0
  - oauth2: 1.16.3
  - password_policy: 1.18.0
  - photos: 2.4.0
  - privacy: 1.12.0
  - provisioning_api: 1.18.0
  - recommendations: 2.0.0
  - related_resources: 1.3.0
  - richdocuments: 8.3.2
  - serverinfo: 1.18.0
  - settings: 1.10.1
  - sharebymail: 1.18.0
  - spreed: 18.0.5
  - support: 1.11.0
  - survey_client: 1.16.0
  - systemtags: 1.18.0
  - text: 3.9.1
  - theming: 2.3.0
  - twofactor_backupcodes: 1.17.0
  - updatenotification: 1.18.0
  - user_status: 1.8.1
  - viewer: 2.2.0
  - weather_status: 1.8.0
  - workflowengine: 2.10.0
Disabled:
  - admin_audit: 1.18.0
  - bruteforcesettings: 2.8.0
  - encryption: 2.16.0
  - suspicious_login: 6.0.0
  - twofactor_totp: 10.0.0-beta.2
  - user_ldap: 1.19.0

Nextcloud Signing status

Exception
Failed to connect to the database: An exception occurred in the driver: could not find driver
Exception thrown: Doctrine\DBAL\Exception```

Nextcloud Logs

Here is the error:
Exception
Failed to connect to the database: An exception occurred in the driver: could not find driver
Exception thrown: Doctrine\DBAL\Exception

Additional info

I have problem with cron jobs first I had ajax but that wasn’t working so today I switched it to cron bt have there too trouble!:
I have done like in the doc described nut I got the error up there I posted!:
sudo crontab -e -u www-data.
I added this line like in the doc:

*/5 * * * * php -f /var/www/nextcloud/cron.php

i’ve also tried to change in the nextcloud config the database ghost from localhost to 172.0.0.1 but it didn’t helped!

that does not look like

*/5 * * * *     sudo -u www php -f /usr/local/www/nextcloud/cron.php

adjust how the user is specified to match your OS, do not run it as the root user.

oh I missed something !

So I changed it to my things:
*/5 * * * * sudo -u www php -f /var/www/nextcloud/cron.php

But I am getting still the error!

And I also tried:
*/5 * * * * sudo -u www-data php -f /var/www/nextcloud/cron.php
becasue I am not sure if www stands for the www-data

Since I changed it in the log is nothing any more but still the error on the cron job page on nextcloud just no logging!

But when I add this back to crontab:
*/5 * * * * php -f /var/www/nextcloud/cron.php
I get the mentioned error back the error why I opened the case but only one time the error occurred nothing after in the log!

The www or www-data is the user that owns the http process. It may be different on your system. An ls -l in your webserver’s home or nextcloud directory should reveal it.

it looks like www-data:

rwxr-xr-x 14 www-data www-data 234 Mar 18 04:44 appdata_occ4rvflt2fo
drwxr-xr-x 2 www-data www-data 35 Mar 8 21:41 files_external
-rwxr-xr-x 1 kali kali 2403 Mar 8 10:04 files_versions
-rw-r–r-- 1 www-data www-data 0 Mar 8 21:41 index.html
drwxr-xr-x 7 www-data www-data 115 Mar 15 00:36 kali
drwxr-xr-x 14 www-data www-data 4096 Mar 8 21:15 nextcloud-dirbkp_20240309
-rw-r----- 1 www-data www-data 0 Mar 18 22:55 nextcloud.log
drwxr-xr-x 6 www-data www-data 89 Mar 14 23:23 tester

I runed the command one time in terminal: sudo -u www-data php -f /var/www/nextcloud/cron.php. and got the error:

(base) kali@ai-cloud:~$ sudo -u www-data php -f /var/www/nextcloud/cron.php

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(1654): OC\DB\Connection->connect()

#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1081): 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(337): OC\DB\Connection->executeQuery()

#4 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(377): Doctrine\DBAL\Query\QueryBuilder->executeQuery()

#5 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()

#6 /var/www/nextcloud/lib/private/AppConfig.php(421): OC\DB\QueryBuilder\QueryBuilder->execute()

#7 /var/www/nextcloud/lib/private/AppConfig.php(187): OC\AppConfig->loadConfigValues()

#8 /var/www/nextcloud/lib/private/AppConfig.php(377): OC\AppConfig->getApps()

#9 /var/www/nextcloud/lib/private/App/AppManager.php(128): OC\AppConfig->getValues()

#10 /var/www/nextcloud/lib/private/App/AppManager.php(149): OC\App\AppManager->getInstalledAppsValues()

#11 /var/www/nextcloud/lib/private/legacy/OC_App.php(231): OC\App\AppManager->getInstalledApps()

#12 /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(90): OC_App::getEnabledApps()

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

#14 /var/www/nextcloud/lib/base.php(1200): OC::init()

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

#16 {main}

To mention I have changed data directory could that be a cause?

I tried the command again in terminal: sudo -u www-data php -f /var/www/nextcloud/cron.php

And now it takes very long and it uses the cpu a lot it takes all it can get from the cpu!

By manually executing the command it took a while but now nextcloud too says job completed!

Now we’re on familiar ground. You can find that error diagnostic in a lot of searches.

I solved it by removing php8.0 and php8.3 but cron seem not t execute the command:

*/5 * * * * sudo -u www-data php -f /var/www/nextcloud/cron.php

It says something seem to be going wrong no job done since 11min where I manually executed the command!

I found the issue throng asking ai:

Mar 19 03:40:01 ai-cloud sudo[20414]: www-data : user NOT in sudoers ; PWD=/var/www ; USER=www-data ; COMMAND=/usr/b>

I just added it to the: sudo crontab -e
*/5 * * * * sudo -u www-data php -f /var/www/nextcloud/cron.php
and that worked!

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.