1

I have an error on CivicCRM v 5.11 "Cron Not Running" (WordPress)

The crontab entry reads

*/5 * * * * /usr/local/bin/cv api --user=www-data job.execute

The cron job fails with:

[Exception] Failed to locate civicrm.settings.php.

so I told bash

CIVICRM_SETTINGS="/var/www/html/wp-content/uploads/civicrm/civicrm.settings.php"

this file is owned by linux user www-data, same as who owns apache

variable assignment echoes back correctly, e.g.:

echo $CIVICRM_SETTINGS /var/www/html/wp-content/uploads/civicrm/civicrm.settings.php

and so I run cv by hand like this:

cv api -vvv Job.execute

and get the same error about not knowing where civicrm.settings.php lives:

Attempting to set verbose error reporting [BaseCommand::boot] Start [BaseCommand::boot] Call standard cv bootstrap [Bootstrap] Options: { "dynamicSettingsFile": "phar:///usr/local/bin/cv/settings_location.php", "env": "CIVICRM_SETTINGS", "prefetch": true, "settingsFile": null, "search": true, "cmsType": null, "httpHost": "", "output": {} } [Bootstrap] Find settings file

[Exception] Failed to locate civicrm.settings.php. By default, this tool searches the parent directories for a standard CMS (Drupal, WordPress, etal) and standard civicrm.settings.php. Symlinks and multisite configurations may interfere. To customize, set variable CIVICRM_S ETTINGS to point to the preferred civicrm.settings.php.

Exception trace: () at phar:///usr/local/bin/cv/src/Bootstrap.php:147 Civi\Cv\Bootstrap->boot() at phar:///usr/local/bin/cv/src/Command/BaseCommand.php:62 Civi\Cv\Command\BaseCommand->boot() at phar:///usr/local/bin/cv/src/Command/ApiCommand.php:48 Civi\Cv\Command\ApiCommand->execute() at phar:///usr/local/bin/cv/vendor/symfony/console/Command/Command.php:257 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/cv/vendor/symfony/console/Application.php:850 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/cv/vendor/symfony/console/Application.php:193 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/cv/vendor/symfony/console/Application.php:124 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/cv/src/Application.php:17 Civi\Cv\Application::main() at phar:///usr/local/bin/cv/bin/cv:22 require() at /usr/local/bin/cv:10

api [--in IN] [--out OUT] [--level LEVEL] [-t|--test] [-U|--user USER] [--] []...

What could I be doing wrong here?

  • 1
    When you set CIVICRM_SETTINGS try prefixing the word export, otherwise child processes don't inherit it. i.e. export CIVICRM_SETTINGS=... – Demerit Mar 12 at 20:50
  • Thanks much for this - and it led to the solution. The solution was a) to chown the /civicrm root to www-data, which had changed to root due to an upgrade and b) give write access to www-data to the /civicrm/templates_c THANKS MUCH for pointing out that bit of bash usage. Appreciate it. – Harrumph Mar 12 at 22:18
  • I'm still confused. While Civi dashboard no longer complains about cron, I'm still getting sysadmin mail indicating : Failed to locate civicrm.settings.php. By default, this tool searches the parent directories for a standard CMS (Drupal, WordPress, etal) and standard civicrm.settings.php. Symlinks and multisite configurations may interfere. To customize, set variable CIVICRM_SETTINGS to point to the preferred civicrm.settings.php. – Harrumph Mar 12 at 22:26
  • Whose crontab is it? Does the crontab belong to a user that doesn't have write access? If that's not it, try wrapping the crontab command in a little script that sets the variable first, then call that script instead from cron. – Demerit Mar 12 at 22:35
  • 1
    No they're separate. And that's another point too: --user in the cv call refers to the CMS user. – Demerit Mar 12 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.