Scheduling
AEM offers a way to execute certain tasks, such as previewing, publishing or purging pages at certain times during the day or in certain periodic intervals. It also allows publishing a query index, which makes entries public in the JSON representation that may have only been available in the underlying Excel workbook or Google spreadsheet.
The tasks to execute and the time they should be executed at are configurable with a crontab
sheet, located in the project’s .helix
folder, that looks as follows:
The sheet should have two columns named when
and command
, containing time and command to execute.
Specifying time
The scheduled time is specified as a text expression and times are expressed in UTC. Some examples follow:
at 7:00 am
Runs at 07:00 UTC every day.
every 60 minutes starting on the 55th min
Runs every hour on the 55th minute
at 3:00 pm on the 18th day of May in 2024
Runs exactly once at 15:00 UTC on 18 May 2024
Note the year in the last example. If this is omitted, you schedule a job that runs again on the same date next year:
at 3:00 pm on the 18th day of May
Runs every year at 15:00 UTC on 18 May
For more information on supported time expressions, see later’s documentation page.
Available tasks
The following table summarizes the tasks available:
Name | Description |
---|---|
preview |
Preview a page. |
publish |
Publish a page, including flushing the cache and indexing the page. |
http |
Execute an HTTP request, which allows purging pages on a CDN that are not automatically purged when a page is published |
publish-index |
Publish an index. |
process |
Process another sheet containing pages to preview, publish and purge. |
The complete reference to those tasks can be found below.
Activate your schedule configuration
When you are finished making changes to your crontab sheet, activate it by previewing it. If there are any syntactical errors, a message will be displayed, and none of your tasks in that sheet will be scheduled.
Run multiple tasks at the same time
You can run multiple tasks at the same time by separating them with a line feed in the cell. If you happen to have a lot of pages to preview, publish and possibly purge at the same time, consider using process
as shown below.
Task reference
preview
Preview a page given as second parameter, e.g.preview /document
preview /spreadsheet.json
publish
Publish a page given as second parameter, e.g.publish /document
publish /spreadsheet.json
http
Execute a HTTP request to the given URL, with an optional method, e.g.http https://www.example.com
http GET https://www.example.com
both issue a GET request to https://www.example.com
publish-index
Publish an index and additionally rebuild the sitemap if there were changes, e.g.publish-index default
publishes the index named default
in helix-query.yaml
.
process
Process a previewed JSON document line by line, interpreting it as a list of commands and their arguments, where the columns are commands and the cell values are arguments.
For example, given the following JSON document called /tasks.json
:
Adding a command process /tasks.json
to your crontab
will preview and publish /document1
, and then preview and publish /document2
.