ibexa

Path

ez publish / technical manual / 3.8 / features / cronjobs / configuring cronjobs


Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

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.

  • The ScriptDirectories configuration array specifies the directories where eZ Publish will search for built-in cronjob scripts (the "cronjobs" directory is used by default).
  • The ExtensionDirectories directive specifies the extension directories where eZ Publish will search for additional/custom cronjob scripts. By default, eZ Publish will search in the "cronjobs" subdirectory inside your extension(s).
  • The Scripts array contains a list of cronjob scripts that will be run when the main "runcronjobs.php" script is executed without specifying the "group_of_tasks" option. The tasks specified in this configuration array is called the main set of cronjobs.

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:

  • workflow.php
  • notification.php
  • linkcheck.php
  • unpublish.php
  • rssimport.php
  • indexcontent.php
  • hide.php
  • subtreeexpirycleanup.php
  • basket_cleanup.php
  • internal_drafts_cleanup.php

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.:

  • Workflow.php and notification.php - every 15 minutes.
  • The basket cleanup, internal drafts cleanup and link check cronjobs - once a week.
  • All other cronjobs - once a day.

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.

Svitlana Shatokhina (24/11/2006 11:49 am)

Svitlana Shatokhina (07/12/2006 9:39 am)

Svitlana Shatokhina, Balazs Halasy


Comments

There are no comments.