Answers.Body: <p>This method of running cron doesn't work with drupal 9. Try using <code>cv</code> instead: see <a href="https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#commands" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#commands</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-28T08:10:11.117Z
Answers.Text: Thanks for the pointer, not sure I can install CV on a shared host without Root access...but will look into it. 
  All advice so far says Cron php should work using the above method...so your the first to suggest otherwise based on my research so far.
  I could also try thr drush method in theory so will try that also.
  thanks
Answers.UserDisplayName: DaveP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-27T01:03:46.557Z
Answers.LastActivityDate: 2022-10-27T01:03:46.557Z
Answers.UserDisplayName: Demerit
Body: <p>I'm using DRUPAL 9 CivicCRM 5.54 and running it on CPanel. This is a new install.</p>
  <p>The cron job on CPanel runs and doesn't generate errors, however the <code>cron.php</code> script doesn't run the <code>job.execute</code> API call.</p>
  <p>CRON JoB is detailed here:</p>
  <pre><code>/usr/local/bin/php /home/changin5/public_html/vendor/civicrm/civicrm-core/bin/cron.php name=admin pass=XXXXXXXXX key=XXXXXXXXXX &gt; /home/changin5/public_html/civicrm.log 2&gt;&amp;1
  </code></pre>
  <p>The <code>CRON.php</code> script has various file paths in it which are not correct as far as I can see.
  I've commented out the actual ones where files exist and left in the original ones in the script, but it doesn't run the jobs!
  Adding in the file paths that are commented out still doesn't run the API call.</p>
  <p>Script Paths:</p>
  <ul>
  <li><p><code>'/public_html/modules/contrib/civicrm/civicrm.config.php.drupal'</code> - this exists</p>
  </li>
  <li><p><code>require_once '../civicrm.config.php';</code> doesn't exist except as above!</p>
  </li>
  <li><p><code>'/home/changin5/public_html/vendor/civicrm/civicrm-core/CRM/Core/Config.php'</code> - this exists</p>
  </li>
  <li><p><code>require_once 'CRM/Core/Config.php';</code></p>
  </li>
  <li><p><code>'/home/changin5/public_html/vendor/civicrm/civicrm-core/CRM/Utils/Request.php'</code> - this exists</p>
  </li>
  </ul>
  <pre><code>require_once 'CRM/Utils/Request.php';
  CRM_Core_Config::singleton();
  CRM_Utils_System::authenticateScript(TRUE);
  
  $job = CRM_Utils_Request::retrieve('job', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
  
  /*'/home/changin5/public_html/vendor/civicrm/civicrm-core/CRM/Core/JobManager.php'*/
  require_once 'CRM/Core/JobManager.php';
  $facility = new CRM_Core_JobManager();
  
  if ($job === NULL) {
    $facility-&gt;execute();
  }
  else {
    $ignored = array(&quot;name&quot;, &quot;pass&quot;, &quot;key&quot;, &quot;job&quot;);
    $params = array();
    foreach ($_REQUEST as $name =&gt; $value) {
      if (!in_array($name, $ignored)) {
        $params[$name] = CRM_Utils_Request::retrieve($name, 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
      }
    }
    $facility-&gt;setSingleRunParams('job', $job, $params, 'From cron.php');
    $facility-&gt;executeJobByAction('job', $job);
  }
  </code></pre>
  <p>Having tried to make these file paths accurate the script still doesn't run, it didn't run with the original paths as the <code>cron.php</code> sits in <code>vendors/civicrm/civicrm-core/bin</code> and calls to file paths in <code>..CRM/Core</code> or <code>..CRM/Utils</code> or both of which exist but <code>../civicrm.config.php</code> doesn't exist!</p>
  <p>Any pointers as to what files this script is meant to be referring to and where they are? And have I got it correct that they should be fully relative paths rather than <code>..CRM</code> etc?</p>
  
Tags: <cron-job><scheduled-job>
Title: Cron job is run but CRON.PHP not executing job
ThreadText: # Cron job is run but CRON.PHP not executing job
  
  (Asked by: username_0 on 2022-10-26)
  
  I'm using DRUPAL 9 CivicCRM 5.54 and running it on CPanel. This is a new install.
  
  The cron job on CPanel runs and doesn't generate errors, however the `cron.php` script doesn't run the `job.execute` API call.
  
  CRON JoB is detailed here:
  
  ```
  /usr/local/bin/php /home/changin5/public_html/vendor/civicrm/civicrm-core/bin/cron.php name=admin pass=XXXXXXXXX key=XXXXXXXXXX > /home/changin5/public_html/civicrm.log 2>&1
  
  ```
  
  The `CRON.php` script has various file paths in it which are not correct as far as I can see.
  I've commented out the actual ones where files exist and left in the original ones in the script, but it doesn't run the jobs!
  Adding in the file paths that are commented out still doesn't run the API call.
  
  Script Paths:
  
  * `'/public_html/modules/contrib/civicrm/civicrm.config.php.drupal'` - this exists
  * `require_once '../civicrm.config.php';` doesn't exist except as above!
  * `'/home/changin5/public_html/vendor/civicrm/civicrm-core/CRM/Core/Config.php'` - this exists
  * `require_once 'CRM/Core/Config.php';`
  * `'/home/changin5/public_html/vendor/civicrm/civicrm-core/CRM/Utils/Request.php'` - this exists
  
  ```
  require_once 'CRM/Utils/Request.php';
  CRM_Core_Config::singleton();
  CRM_Utils_System::authenticateScript(TRUE);
  
  $job = CRM_Utils_Request::retrieve('job', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
  
  /*'/home/changin5/public_html/vendor/civicrm/civicrm-core/CRM/Core/JobManager.php'*/
  require_once 'CRM/Core/JobManager.php';
  $facility = new CRM_Core_JobManager();
  
  if ($job === NULL) {
    $facility->execute();
  }
  else {
    $ignored = array("name", "pass", "key", "job");
    $params = array();
    foreach ($_REQUEST as $name => $value) {
      if (!in_array($name, $ignored)) {
        $params[$name] = CRM_Utils_Request::retrieve($name, 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
      }
    }
    $facility->setSingleRunParams('job', $job, $params, 'From cron.php');
    $facility->executeJobByAction('job', $job);
  }
  
  ```
  
  Having tried to make these file paths accurate the script still doesn't run, it didn't run with the original paths as the `cron.php` sits in `vendors/civicrm/civicrm-core/bin` and calls to file paths in `..CRM/Core` or `..CRM/Utils` or both of which exist but `../civicrm.config.php` doesn't exist!
  
  Any pointers as to what files this script is meant to be referring to and where they are? And have I got it correct that they should be fully relative paths rather than `..CRM` etc?
  
  **Tags:** cron-job, scheduled-job
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-10-27. Score: 0
  
  This method of running cron doesn't work with drupal 9. Try using `cv` instead: see <https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#commands>
  
  > **Comments:**
  > **username_0**: Thanks for the pointer, not sure I can install CV on a shared host without Root access...but will look into it.  All advice so far says Cron php should work using the above method...so your the first to suggest otherwise based on my research so far. I could also try thr drush method in theory so will try that also. thanks  
  
  ---
  
  