Dev Guide
Dev GuideUser GuidesLegal TermsGitHubDevCommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Job cron expression

There are different ways to trigger OCP jobs:

  • Trigger the job by another part of the app such as 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> 

Scheduling jobs with cron expressions

Use cron property in app manifest file (app.yml) to scheduler regular execution of a job.
The property uses quartz cron format.
Examples:

ExpressionDescription
* * ? *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 also use:
https://www.freeformatter.com/cron-expression-generator-quartz.html

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 isn't provided or needed in real time