About cron jobs
Cron jobs offer a powerful and flexible scheduling mechanism for automating tasks, orchestrations, workflows and background jobs. With built-in support for time zones and support for daylight time transitions, you can define schedules that align with regional requirements, ensuring tasks are executed at the right time, regardless of geographic location.
Cron 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 support
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
Daylight saving time
Since Taskurai uses the Cronos library, it benefits from the intuitive way how daylight saving is handled. Read more about Cronos daylight saving time.
Retry behavior
Unlike the default task retry policy, tasks generated by cron jobs do not automatically retry upon failure, but rather wait for the next task to be scheduled. To customize this behavior, you can define a specific retry policy in the task configuration of the cron job.
Scheduling behavior
Cron jobs are scheduled like normal tasks in Taskurai, sharing the same queues and workers of the specified command. The cron job is always scheduled to start after the scheduled time, it will not take priority in the queue and will be started when a worker is available.
To prevent tasks from starting after a due time, specify the notStartAfter in the task execution options.
Misfire policy
In the rare occasion where Taskurai is not able to schedule the task on time (eg. due to a scheduler failure, stressed system, etc.), it is possible to specify a misfire policy:
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.
Isolation mode
Cron jobs support isolation mode. When cron jobs are created in isolation mode, the generated tasks will be generated in the same isolation mode and isolation key for development purposes. When listing cron jobs in isolation mode, by default, only items belonging to the isolated session will be returned.