Skip to end of metadata
Go to start of metadata


Documentation Search


CiviCRM 4.3 Documentation

Developer Resources


CiviCRM books!

Make sure to check out our Online User/Administrator and Developer Guides! You can also support this project by ordering a hard copy.

Or support us by buying an eBook or hard copy of Using CiviCRM from Packt Publishing.

CiviCRM scheduled jobs (background processing tasks) can be run using the HTTP GET or POST methods. This is an alternative to using PHP Cli which is documented here. The GET method is slightly easier to configure, but may be considered less secure since authentication information is included in the command line, and therefore may be visible to other users with sufficient permissions on your server. Examples of both methods are included below. Information for run

Make sure there that there are no reserved or unsafe URL characters in your username or password. These include:

and spaces.

Run Scheduled Jobs using POST Method

When using the POST method, the username and password values are written to a text file, and then that filename is specified when running the script.

EXAMPLE: Use "wget" to send queued CiviMail mailings (Drupal installation)

1) Create a file named civicrm-wgetrc that contains this line (replacing username, password and site-key with the actual values).

2) Create a script that contains these lines:

EXAMPLE: Use curl to send queued CiviMail mailings (Drupal installation)

1) Create a file named civicrm-curl that contains this line (replacing <username>, <password> and <site-key> with the actual values).

2) Create a script that contains this command:

ALTERNATIVE curl calling syntax

Check the curl documentation for information about logging and console output options.

Run Scheduled Jobs using GET Method

When using the GET method, the username, password and site-key values are passed in the URL (as well as any required job-specific parameters).

EXAMPLE: Use "wget" to run the Update Membership script - replacing <username>, <password> and <site-key> with the actual values (Drupal installation)

EXAMPLE: Use "curl" to run the Update Membership script - replacing <username>, <password> and <site-key> with the actual values (Drupal installation)

Check the curl documentation for information about logging and console output options.

Example CRON

A cron can be configured to run either a script in a directory or to use WGET.  This example is just one of the many ways to configure a cron, which uses WGET to run the CiviCRM consolidated schedule job every 5 minutes for a Drupal + CiviCRM installation.  The wget flags ( -O -q -t etc ) discard the output thereby running the wget silently.  Note that this method saves your username and password in the crontab itself and may not be suitable in some situations.

  1. Login to your server using SSH, or via your control panel
  2. Access cron by:
    1. crontab -e
    2. env EDITOR=nano crontab -e
    3. click the Cron Job icon in your control panel
  3. Use the example below as a single line in the cron, replacing your actual domain, username, password and key
  4. Notice the use of quotes around the url-this is necessary if the query string contains an ampersand (&)
  5. Save
  6. Wait a few minutes and check if the scheduled jobs have executed properly

Cron.php will run jobs with API entity=job only

Note that you can execute API actions only from the API entity "job"; this is hard-coded into cron.php.  So you can't call any of the built in API functions (other than those under entity "job") using cron.php, but you also can't create a new API action  So for instance, if you create new API entity called "myapi" with API action "my action" then you would be able to call that action via the Scheduled Jobs page but you will not be able to call it via cron.php.

A possible workaround for this problem is here: http://forum.civicrm.org/index.php/topic,28215.0.html

Labels
  • None