Using Cron to trigger php jobs

CiviCRMCron allows you to trigger php jobs periodically. In CiviCRM this includes triggering mailouts for example. This article describes setting up Cron using the cPanel cron jobs tool.


Site key

Start by accessing the root directory with your preferred file browser.

  1. In Joomla, browse to /administrator/components/com_civicrm/
  2. Open the civicrm.settings.php file for editing.
  3. Find the following line (maybe line 284):
define( 'CIVICRM_SITE_KEY', '26ef1a41b2f4a1246b58b345e4b28bab');

This is your automatically created site key, that you'll need in the next step.

 

Cron Job

Log on to your web hosts cPanel.

  1. Click the Cron Jobs icon.
    1. If it's not available you'll need to contact your web host.
  2. In the Add a New Cron Job section, configure the schedule (e.g. */15 * * * *
  3. In the Command: box, enter the following command and click the Add New Cron Job button.
curl --silent --compressed 'https://yoursite.org/administrator/components/com_civicrm/civicrm/bin/cron.php?name=username&pass=password&key=26ef1a41b2f4a1246b58b345e4b28bab'  > /dev/null 2>&1

Name is your Joomla super admin username, and pass is the user's password. The --silent option stops the progress bar appearing, and the --compressed option allows curl to request a compressed response, neither are necessary for the cron job to work and the compressed option may not be supported on your host. The > /dev/null 2>&1 option sends the output to a null file, preventing an email being sent, and was required by my host, but might not be needed for your host.

 

Managing CiviCRM jobs

Now that your cron job has been created, you can manage various CiviCRM jobs.

  1. Go to Administer > System Settings > Schedule Jobs.
  2. At your discretion, you might want to enable the following jobs.
    1. Clean-up temp data and files (Hourly)
    2. Disable expired relationships (Daily)
    3. Fetch bounces (Hourly)
    4. Geocode and parse addresses (Daily)
    5. Process inbound e-mails (Hourly)
    6. Process Survey Respondents (Always)
    7. Rebuild Smart Group Cache (Always)
    8. Send Scheduled Mailings (Always)
    9. Send Scheduled Reminders (Daily)
    10. Update Participant Statuses (Always)
    11. Validate Email Address from Mailings. (Daily)

 

Thanks for visiting.