Body: <p>I have an error on CivicCRM v 5.11 "Cron Not Running" (WordPress)</p>
  
  <p>The crontab entry reads</p>
  
  <blockquote>
    <p>*/5 * * * * /usr/local/bin/cv api --user=www-data job.execute</p>
  </blockquote>
  
  <p>The cron job fails with:</p>
  
  <blockquote>
    <p>[Exception]   Failed to locate civicrm.settings.php.</p>
  </blockquote>
  
  <p>so I told bash</p>
  
  <blockquote>
    <p>CIVICRM_SETTINGS="/var/www/html/wp-content/uploads/civicrm/civicrm.settings.php"</p>
  </blockquote>
  
  <p>this file is owned by linux user www-data, same as who owns apache</p>
  
  <p>variable assignment echoes back correctly, e.g.:</p>
  
  <blockquote>
    <p>echo $CIVICRM_SETTINGS
    /var/www/html/wp-content/uploads/civicrm/civicrm.settings.php</p>
  </blockquote>
  
  <p>and so I run cv by hand like this:</p>
  
  <blockquote>
    <p>cv api -vvv Job.execute</p>
  </blockquote>
  
  <p>and get the same error about not knowing where civicrm.settings.php lives:</p>
  
  <blockquote>
    <p>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</p>
    
    <p>[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.</p>
    
    <p>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</p>
    
    <p>api [--in IN] [--out OUT] [--level LEVEL] [-t|--test] [-U|--user USER]
    [--]  []...</p>
  </blockquote>
  
  <p>What could I be doing wrong here?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T20:50:01.600Z
Comments.Text: When you set CIVICRM_SETTINGS try prefixing the word export, otherwise child processes don't inherit it. i.e. export CIVICRM_SETTINGS=...
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T22:18:34.437Z
Comments.Text: 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.
Comments.UserDisplayName: Harrumph
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T22:26:57.930Z
Comments.Text: 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.
Comments.UserDisplayName: Harrumph
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T22:35:14.123Z
Comments.Text: 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.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T22:44:34.880Z
Comments.Text: With the crontab entry being 
  
  */5 * * * * /usr/local/bin/cv api --user=www-data job.execute
  
  this means the user running the job is www-data, no?
Comments.UserDisplayName: Harrumph
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-12T23:12:28.623Z
Comments.Text: No they're separate. And that's another point too: --user in the cv call refers to the CMS user.
Comments.UserDisplayName: Demerit
Tags: <civicrm.settings.php><cv>
Title: cv fails to locate civicrm.settings.php
ThreadText: # cv fails to locate civicrm.settings.php
  
  (Asked by: username_0 on 2019-03-12)
  
  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?
  
  **Tags:** civicrm.settings.php, cv
  
  > **Comments:**
  > **username_1**: When you set CIVICRM_SETTINGS try prefixing the word export, otherwise child processes don't inherit it. i.e. export CIVICRM_SETTINGS=...  
  > **username_0**: 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.  
  > **username_0**: 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.  
  > **username_1**: 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.  
  > **username_0**: With the crontab entry being   */5 * * * * /usr/local/bin/cv api --user=www-data job.execute  this means the user running the job is www-data, no?  
  > **username_1**: No they're separate. And that's another point too: --user in the cv call refers to the CMS user.  
  
  ---
  
  ## 0 answers
  
  