Skip to main content

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 zone America/New_York, with misfire policy MostRecentCatchUp, a task with command AggregateDailSalesSAP for the region USA. When the task fails to start with the hour, the task is marked as expired.
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

PropertyTypeRequiredAdditional requirementsDescription
namestringNo1-20 alphanumeric characters and hyphensOverride cron job name (default: cron job key)
descriptionstringNoCron job description
scheduleCron job formatYesCronos-compatible Cron schedule (Taskurai uses Cronos library (https://github.com/HangfireIO/Cronos) to parse CRON statements)
timeZoneTime zoneNoIANA or Windows compatible time zone name
misfirePolicyMisfire policyNoCron job misfire policy
categorystringNoCron job category
externalIdstringNoCron job external ID
externalAccountIdstringNoCron job external account ID
externalUserIdstringNoCron job external user ID
tagsobjectNoCron job tags (dictionary)
unlistedbooleanNoMark Cron job as unlisted
taskConfigTask configurationYesTask configuration
isolationModebooleanNoRun the task in isolation mode
isolationKeystringNoIsolation key
includeSensitivebooleanNoOverride default to turn off sensitive data in return data

Misfire policy

Misfire policyDescription
SkipThe task generation of the overdue tasked is skipped.
CatchUpAllAll overdue tasks are generated.
MostRecentCatchUpOnly 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}

PartAllowed valuesAllowed special charactersComment
second0-59* , - /
minute0-59* , - /
hour0-23* , - /
day of month1-31* , - / L W ?
month1-12 or JAN-DEC* , - /
day of week0-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