1

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?

1 Answer 1

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

1
  • 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
    – DaveP
    Commented Oct 28, 2022 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.