DataWorks cron expressions

更新时间:
复制 MD 格式

Learn the cron expression syntax for scheduling tasks in DataWorks, including field definitions, special characters, and common examples.

Overview

Important

Using a custom expression for the scheduling time is an invitation-only beta feature. To use this feature, contact technical support.

DataWorks defines task scheduling time through a form or a custom expression (time property configuration). Cron expressions follow the standard Spring Cron format (CronSequenceGenerator), extended to support last-day-of-month and Nth-weekday-of-month scheduling.

Note: Switching between form and custom expression modes resets the scheduling time to the default value (00 00 00 * * ?). You must reconfigure it after switching.

Cron expressions support flexible scheduling. You can:

  • Specify exact dates

  • Handle month-end processing (using L)

  • Combine multiple values (for example, 1,3)

  • Specify the last day of the week in a month (L) or the Nth day of the week in a month (#)

DataWorks uses a six-field format:

second minute hour day of month month day of week

Example: Run a task at 01:00:00 on the 1st and 3rd of every month.

00 00 01 1,3 * ?
Important
  • Second-level scheduling is not supported. The second field must be 00.

  • The year field is not supported. All tasks run annually by default.

Field reference

Position

Field

Value range

Special characters

Description

1

second

00

-

Not configurable.

2

minute

0-59

, - * /

-

3

hour

0-23

, - * /

24-hour clock

4

day of month

1-31

, - * / L

Specifies the day of the month. L indicates the last day of the month.

5

month

1-12

, - * /

-

6

day of week

  • Standalone: 0-6

  • With L or #: 1-7

Important

English abbreviations (such as FRI and MON) and full names are not supported.

, - * / L #

  • Standalone: 0 = Sunday, 1 = Monday, 7 = Saturday

  • With L or #:

    • 6L: The last Friday of the month

    • 5#1: The first Thursday of the month

Special characters

Character

Name

Description

*

Wildcard

Represents all possible values. For example, * in the hour field means every hour.

?

No specific value

Used in the day of month or day of week field when no specific value is needed. For example, to run every Monday, set day of month to ?.

-

Range

Specifies a contiguous range. For example, 10-12 in the hour field means 10:00, 11:00, and 12:00.

,

List

Specifies discrete values. For example, 1,3,5 in the month field means January, March, and May.

/

Increment

Defines a step interval. For example, 0/15 in the minute field means every 15 minutes starting from 0.

L

Last

  • In the day of month field, L indicates the last day of the month.

  • In the day of week field, L indicates the last occurrence of a specific weekday in the month. Must be combined with a number (e.g., 6L).

#

Nth Day

Used in the day of week field. Format: A#B = the Bth occurrence of day A in the month. For example, 4#1 = the first Wednesday.

Syntax details and examples

1. Enumerate multiple dates: ,

00 00 00 1,15 * ?
Run at 00:00:00 on the 1st and 15th of every month (commonly used for bimonthly paydays or reconciliation)

2. Use L: Last day of the month or last day of the week in a month

00 00 00 L * ?
Run at 00:00:00 on the last day of every month (month-end settlement)
00 00 00 * * 7L
Run at 00:00:00 on the last Saturday of every month
00 00 00 ? * 2L
Run at 00:00:00 on the last Monday of every month

3. Use #: Nth day of the week in a month

00 00 00 ? * 3#2
Run at 00:00:00 on the second Tuesday of every month
00 00 00 * * 6#3
Run at 00:00:00 on the third Saturday of every month
⚠️ If the fifth Saturday does not exist in a given month, the task is skipped for that month.

4. Combined expressions (recommended for complex schedules)

00 00 00 1,3 * 6L
Run at 00:00:00 on the 1st, 3rd, and last Friday of every month

Common use cases

Cron expression

Description

00 00 02 * * ?

Run at 02:00:00 every day.

00 15 10 * * ?

Run at 10:15:00 every day.

00 0/5 14-15 * * ?

Run every 5 minutes from 14:00 to 15:00 every day.

00 00 01 ? * 1

Run at 01:00:00 every Monday.

00 00 02,4 ? * 4

Run at 02:00:00 and 04:00:00 every Thursday.

00 00 02 L * ?

Run at 02:00:00 on the last day of every month.

00 00 02 ? * 6L

Run at 02:00:00 on the last Friday of every month.

00 00 01 ? * 4#1

Run at 01:00:00 on the first Wednesday of every month.

00 00 01 3 * 4#1

Run at 01:00:00 on the 3rd and the first Wednesday of every month.