Cron job configuration
In this section, you will learn how to set up cron jobs in Taskurai.
Cron jobs can defined in the Taskurai configuration (YAML) and are deployed and managed using the Taskurai CLI.
Cron jobs deployment configuration
A cron job is deployed using a configuration section in the solution yaml.
Reference cron job configuration
This is a reference cron job configuration sample:
- AggregateDailySales:
- Each night at
2AM (02:00), in time zoneAmerica/New_York, with misfire policyMostRecentCatchUp, a task with commandAggregateDailSalesSAPfor the regionUSA. When the task fails to start with the hour, the task is marked as expired.
- Each night at
cronJobs:
AggregateDailySales:
description: Aggregate daily sales and upload to SAP
schedule: 0 0 2 * * *
timeZone: America/New_York
misfirePolicy: MostRecentCatchUp
category: Sales
taskConfig:
command: AggregateDailSalesSAP
arguments:
- name: region
value: USA
executionOptions:
notStartAfter:
seconds: 3600
Cron job configuration
| Property | Type | Required | Additional requirements | Description |
|---|---|---|---|---|
name | string | No | 1-20 alphanumeric characters and hyphens | Override cron job name (default: cron job key) |
description | string | No | Cron job description | |
schedule | Cron job format | Yes | Cronos-compatible Cron schedule (Taskurai uses Cronos library (https://github.com/HangfireIO/Cronos) to parse CRON statements) | |
timeZone | Time zone | No | IANA or Windows compatible time zone name | |
misfirePolicy | Misfire policy | No | Cron job misfire policy | |
category | string | No | Cron job category | |
externalId | string | No | Cron job external ID | |
externalAccountId | string | No | Cron job external account ID | |
externalUserId | string | No | Cron job external user ID | |
tags | object | No | Cron job tags (dictionary) | |
unlisted | boolean | No | Mark Cron job as unlisted | |
taskConfig | Task configuration | Yes | Task configuration | |
isolationMode | boolean | No | Run the task in isolation mode | |
isolationKey | string | No | Isolation key | |
includeSensitive | boolean | No | Override default to turn off sensitive data in return data |
Misfire policy
| Misfire policy | Description |
|---|---|
Skip | The task generation of the overdue tasked is skipped. |
CatchUpAll | All overdue tasks are generated. |
MostRecentCatchUp | Only the most recent overdue task is generated. |
Cron job format
Taskurai uses the Cronos library to interpret Cronos-compatible cron expressions. The Taskurai's cron expression is similar to a CRON expression except that it includes an additional sixth field at the beginning to use for time precision in seconds.
{second} {minute} {hour} {day} {month} {day-of-week}
| Part | Allowed values | Allowed special characters | Comment |
|---|---|---|---|
| second | 0-59 | * , - / | |
| minute | 0-59 | * , - / | |
| hour | 0-23 | * , - / | |
| day of month | 1-31 | * , - / L W ? | |
| month | 1-12 or JAN-DEC | * , - / | |
| day of week | 0-6 pr SUN-SAT | * , - L # L ? | Both 0 and 7 means SUN |
Time zone
By default, all calculations are done in UTC. It is possible to specify a timezone for each cron job entry. Time zones can be specified in IANA, Windows time zone names.
Examples:
- IANA:
America/New_York - Windows:
Eastern Standard Time