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" (see example 2).

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[]=workflow.php
Scripts[]=notification.php
Scripts[]=linkcheck.php
Scripts[]=unpublish.php
Scripts[]=rssimport.php
Scripts[]=indexcontent.php
Scripts[]=hide.php
Scripts[]=subtreeexpirycleanup.php
Scripts[]=basket_cleanup.php
Scripts[]=internal_drafts_cleanup.php
ExtensionDirectories[]

This means that the main set of cronjobs contains the following ten 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.

Example 2

To be able to run the cronjobs separately, 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):

[CronjobSettings]
Scripts[]=hide.php
Scripts[]=indexcontent.php
Scripts[]=ldapusermanage.php
Scripts[]=rssimport.php
Scripts[]=subtreeexpirycleanup.php
Scripts[]=unpublish.php
Scripts[]=updateviewcount.php
 
[CronjobPart-infrequent]
Scripts[]=basket_cleanup.php
Scripts[]=internal_drafts_cleanup.php
Scripts[]=linkcheck.php
 
[CronjobPart-frequent]
Scripts[]=notification.php
Scripts[]=workflow.php

In this case, the main set of cronjobs will only contain seven scripts that are listed under the "[CronjobSettings]" section. These scripts will be run when the "runcronjobs.php" script is executed in the following way:

php runcronjobs.php -s example

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

php runcronjobs.php infrequent -s example

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

php runcronjobs.php frequent -s example

However, you may need to divide cronjobs into a couple of groups/sets and run them separately because some tasks must be executed more frequently than others.

With this configuration, you will be able to run each set of cronjobs separately, e.g.:

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.