You should configure a separate cron entry for CiviCRM on your server. CiviCRM's Managing Scheduled Jobs is the reference documentation here.
Best practice is to run your CiviCRM cron separately.
- Many CiviCRM tasks (eg delivering large email runs) are not suited to Drupal's typical cron schedule.
- Running CiviCRM cron from Drupal means that an issue with another Drupal module timing out or causing cron to fail may prevent CiviCRM tasks running.
- Likewise, running CiviCRM cron from within Drupal might prevent other Drupal cron tasks firing if CiviCRM cron timed out or failed.
While it may be possible to configure Drupal to run CiviCRM's cron (eg CiviCRM Cron or Elysia Cron modules), I wouldn't recommend that approach.
Things to check when debugging CiviCRM cron -
- Are you calling cron from the same user account that your webserver runs as? CiviCRM cron tasks may write access to the
templates_c/ directory and can fail if called as a user which can't write there.
- Do the tasks execute when called from the CiviCRM Scheduled Tasks page? Visit
civicrm/admin/job?reset=1 then click More > Execute Now
- Is there output from the PHP command to execute CiviCRM cron? If so it may indicate errors. Use
su to assume the user account your webserver runs as when doing this.
Since we use Drupal extensively with CiviCRM, we fire most site crons using
drush -u 1 @example.org civicrm-api job.execute auth=0 --out=json
where @example.org is a configured alias for the site in question.
We call CiviCRM cron frequently (max wait for a site is a few minutes) to reduce wait time and avoid queue buildups.
A cron entry for a site might look like this in
*/7 * * * * www-data drush -u 1 @example.org civicrm-api job.execute auth=0 --out=json
... but you'll need to adjust this for your environment. You might want to call specific tasks frequently and others once a week; you definitely would need to check the user, Drush alias, and path to Drush shown above!
We also route our cron output to syslog for analysis, but that's well outside the scope of this. CiviCRM cron doesn't set the Drush output status (
$type parameter) as other Drush commands do.