Path

7x / documentation / ez publish / technical manual / 3.10 / features / cronjobs / configuring cronjobs


Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

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

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:

  • unpublish.php
  • rssimport.php
  • indexcontent.php
  • hide.php
  • subtreeexpirycleanup.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.

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

  • Workflow.php and notification.php - every 15 minutes.
  • The basket cleanup and link check cronjobs - once a week.
  • The main set of cronjobs - once a day.

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.

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

Svitlana Shatokhina (21/03/2007 9:33 am)

Svitlana Shatokhina, Balazs Halasy


Comments

There are no comments.