Schedule jobs using cron expressions
Schedule jobs with cron
expressions for an Optimizely Connect Platform (OCP) app,
There are different ways to trigger OCP jobs:
- Trigger the job by another part of the app, like a form
- Use a cron expression to run the job periodically on a given schedule
- Use opti-cli command:
opti jobs trigger <appId> <jobName> <trackerId>
Schedule jobs with cron expressions
Use the cron
property in the app manifest file (app.yml
) to schedule the regular execution of a job. The property uses quartz cron format.
Examples:
Expression | Description |
---|---|
- - ? * | Every second |
0 _ ? _ | Every minute |
0 /2 ? * * | Every even minute |
0 /2 ? * * | Every 2 minutes |
0 /5 ? * * | Every 5 minutes |
0 /10 ? * * | Every 10 minutes |
0 /15 ? * * | Every 15 minutes |
0 /30 ? * * | Every 30 minutes |
0 15,30,45 ? * | Every hour at minutes 15, 30 and 45 |
0 0 /2 ? * | Every hour |
0 0 0/2 ? * * | Every even hour |
0 0 /12 ? * | Every twelve hours |
0 0 12 * * ? | Every day at noon - 12pm |
0 0 12 ? * | SUN Every Sunday at noon |
To build your own cron expression, you can use a free formatter.
Example of YAML configuration:
jobs:
nightly_import:
entry_point: NightlyImport
# runs at midnight every night
cron: 0 0 0 ? * *
description: Performs a nightly import for data that is not provided or needed in real time
Updated 16 days ago