Periodic command scheduling

Structr provides a service for periodic command scheduling: the CronService.

The CronService is a background service that can be configured in the structr.conf configuration file to schedule the execution of periodic tasks. Tasks in this context are either names of schema methods, or fully qualified Java class names of a class implementing the Task interface from the Structr Java API.

The main configuration key for tasks is CronService.tasks. It accepts a whitespace-separated list of schema method names or java class names.

CronService.tasks = cleanUpMethod1 org.structr.example.PeriodicExampleTask exampleMethod

For each of the entries in the above line, you can configure an execution time and date similar to crontab entries in Unix-based operating systems.

The cronExpression in Structr can be configured as <methodName>.cronExpression = <s> <m> <h> <dom> <m> <dow>.
Structr will then run the specified tasks with the configured frequency as the admin user.

Field Explanation
<methodName>name of the global schema method
<s>seconds of the minute
<m>minute of the hour
<h>hour of the day
<dom>day of the month
<m>month of the year
<dow>day of the week


# Run every 30 minutes
cleanUpMethod1.cronExpression = 0 0,30 * * * *

# Run every day at 4:00
org.structr.example.PeriodicExampleTask.cronExpression = 0 0 4 * * *

# Run each hour on Mondays during the first 10 days in April and October
exampleMethod.cronExpression = 0 0 * 1-10 4,10 1
About this article
Last change 2017-08-17