Configuring cronjobs

You can configure which cronjob that will be enabled (can be executed by the "runcronjobs.php" script) from within an override for the "settings/cronjob.ini" configuration file. The following list reveals which settings that can be specified in the "[CronjobSettings]" section of this file.

Cronjob parts

Some cronjobs must be executed more frequently than others. It is possible to configure additional sets of cronjobs by adding specific sections (cronjob parts) to an override for "cronjob.ini".

The next examples demonstrate how the cronjobs can be configured.

Example 1 (default settings)

The following settings are specified in the "[CronjobSettings]" section of "cronjob.ini" by default:

[CronjobSettings]
ScriptDirectories[]=cronjobs
Scripts[]=unpublish.php
Scripts[]=rssimport.php
Scripts[]=indexcontent.php
Scripts[]=hide.php
Scripts[]=subtreeexpirycleanup.php
Scripts[]=internal_drafts_cleanup.php
ExtensionDirectories[]

This means that the main set of cronjobs contains the following six tasks:

These scripts will be run each time the "runcronjobs.php" script is executed without the "group_of_tasks" option. The system will expect these scripts to be located in the "cronjobs" directory.

The following configuration blocks (cronjob parts) located in the "settings/cronjob.ini" configuration file specify two additional sets of cronjobs called "infrequent" and "frequent":

[CronjobPart-infrequent]
Scripts[]=basket_cleanup.php
Scripts[]=linkcheck.php
 
[CronjobPart-frequent]
Scripts[]=notification.php
Scripts[]=workflow.php

The settings located in the "[CronjobPart-infrequent]" section instruct the system to run the "basket_cleanup.php" and "linkcheck.php" scripts when the "runcronjobs.php" script is executed in the following way:

php runcronjobs.php infrequent

The "frequent" set of tasks only includes the notification and work-flow cronjobs. These scripts will be run when the "runcronjobs.php" script is executed in the following way:

php runcronjobs.php frequent

With this configuration, it is possible to run each set of cronjobs separately, e.g.:

Example 2

If you wish to run the "old_drafts_cleanup.php" cronjob once a month, you can add the following settings to the "cronjob.ini.append.php" file located in the "settings/siteaccess/example" directory (replace "example" by the actual name of the siteaccess):

[CronjobPart-monthly]
Scripts[]=old_drafts_cleanup.php

The settings located in the "[CronjobPart-monthly]" section will instruct the system to run the "old_drafts_cleanup.php" cronjob script when the "runcronjobs.php" script is executed in the following way:

php runcronjobs.php monthly -s example

Example 3

It is possible to extend the system by creating custom cronjob scripts. For example, if you have an extension "nExt" that includes a cronjob script "myjob.php", you'll need to put the following lines into an override for the "cronjob.ini" configuration file:

[CronjobSettings]
ExtensionDirectories[]=nExt
Scripts[]=myjob.php

or

[CronjobSettings]
ScriptDirectories[]=extension/nExt/cronjobs
Scripts[]=myjob.php

These settings will make eZ Publish expect the additional cronjob script to be located at "extension/nExt/cronjobs/myjob.php". This script will be added to the main set of cronjobs and thus it will be run each time the "runcronjobs.php" script is executed without the "group_of_tasks" option.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.