The Magnolia Scheduler module allows you to schedule commands to run at regularly scheduled times and is powered by the Quartz Engine.
Maven is the easiest way to install the module. Add the following dependency to your bundle:
<dependency> <groupId>info.magnolia</groupId> <artifactId>magnolia-module-scheduler</artifactId> <version>2.3.1</version> </dependency>
Pre-built jars are also available for download. See Installing a module for help.
The Scheduler module can be used to execute any configured command at regular intervals. For example, it can:
- Activate or deactivate a promotional web page on a specific date.
- Import content from an external source into a Magnolia workspace.
- Send emails on specific days.
- Delete specified forum messages or threads.
- Synchronize target and source instances.
- Execute a custom command.
Scheduled tasks are configured in
demo job that activates the
/news page hourly.
|0 0 * * * *|
|activate each hour the page news.html|
Name of the job.
Parameters passed to the command. Depends on the command. For example, the
Name of the catalog where the command resides
Name of the command
CRON expression that sets the scheduled execution time. For example
Description of the job
optional, default is
Enables and disables the job.
optional, default is
Whether the job can be executed concurrently.
Scheduling tasks on cluster nodes
In a clustered configuration one or more workspaces is stored in a shared, clustered storage. See Cfor more. Cluster nodes (Magnolia instances) access the clustered workspace rather than their own workspaces. This can lead to a situation where multiple scheduled jobs attempt to access the same content simultaneously and a lockup occurs. To avoid this situation, identify the cluster nodes and run the job on only one node.
- Set the
magnolia.clusteridproperty in the
magnolia.propertiesfile of the cluster node. The file is in the
/<CATALINA_HOME>/webapps/<contextPath>/WEB-INF/config/defaultfolder. The property value can be a literal cluster name such as
magnolia.clusterid=public123) or a variable such as
- To configure the job to run on the identified cluster node, go to
jobsand edit the job configuration.
paramsnode, add a
clusterIdproperty and set the value to match the
magnolia.clusterIdof the cluster node where you want to run the job.
Node name Value
Job configurations are stored in the
config workspace. If you want to run a particular job on all cluster nodes you would have to cluster the
config workspace so that all instances can read the configuration or create the same job configuration on all cluster nodes. This can be time consuming. As a workaround, configure the job once on a clustered instance without the
clusterId property. This has the effect that the job will run on all cluster nodes.