To run a CiviCRM scheduled job using drupal cron we can follow the following steps:

  • Create a user in drupal having permission to run cron. This username and password is required to form the url to call the scheduled job.
  • In any custom module implement  ‘hook_cron’.
  • In the hook implementation, call the url for the scheduled job using curl.
  • The format of the url to run the scheduled job is as below:
  • This will run all scheduled jobs. To run a specific job we have to pass job=<api_action> and othere required parameters for that job.
    The value of <api_action> can be seen in the list of scheduled jobs in CiviCRM.

    The value of ‘site-key’ is in CIVICRM_SITE_KEY constant.
  • For example getting url to run the ‘Update Membership Statuses and Send Renewal Reminders’ job:

    global $base_url;

Add new comment