Cron

更新时间:
复制 MD 格式

Cron is a time-based job scheduler in Unix-like operating systems that runs jobs, such as commands and scripts, at fixed times or intervals.

Important
  • The Professional Edition supports second-level precision for Cron jobs.

  • The Basic Edition does not support second-level precision for Cron jobs. Use second_delay instead.

Cron expressions

A cron expression has the following format: Seconds Minutes Hours Day-of-month Month Day-of-week [Year].

The following table lists common cron expressions.

Cron expression

Description

0 */1 * * * ?

Triggers every minute.

0 0 5-15 * * ?

Triggers on the hour from 05:00 to 15:00 daily.

0 0/3 * * * ?

Triggers every 3 minutes.

0 0-5 14 * * ?

Triggers every minute from 14:00 to 14:05 daily.

0 0/5 14 * * ?

Triggers every 5 minutes from 14:00 to 14:55 daily.

0 0/5 14,18 * * ?

Triggers every 5 minutes from 14:00 to 14:55 and from 18:00 to 18:55 daily.

0 0/30 9-17 * * ?

Triggers every 30 minutes from 09:00 to 17:00 daily.

0 0 10,14,16 * * ?

Triggers at 10:00, 14:00, and 16:00 daily.

0 0 12 ? * WED

Triggers at 12:00 every Wednesday.

0 0 17 ? * TUES,THUR,SAT

Triggers at 17:00 every Tuesday, Thursday, and Saturday.

0 10,44 14 ? 3 WED

Triggers at 14:10 and 14:44 on every Wednesday in March.

0 15 10 ? * MON-FRI

Triggers at 10:15 from Monday through Friday.

0 0 23 L * ?

Triggers at 23:00 on the last day of every month.

0 15 10 L * ?

Triggers at 10:15 on the last day of every month.

0 15 10 ? * 6L

Triggers at 10:15 on the last Friday of every month.

0 15 10 * * ? 2005

Triggers at 10:15 every day in 2005.

0 15 10 ? * 6L 2002-2005

Triggers at 10:15 on the last Friday of every month from 2002 to 2005.

0 15 10 ? * 6#3

Triggers at 10:15 on the third Friday of every month.

Cron job configuration

To schedule a job with a cron expression, see Create a job. This section covers only the timing configuration for Cron-based schedules.

  1. Navigate to the Timing configuration step. For details, see Create a job.

  2. In the Timing configuration step of the Add Task wizard, set the scheduling parameters and then click Next.

    1. From the Time type drop-down list, select Cron.

    2. Set the cron expression.

      Use the build tool to generate cron expressions for simple scheduling rules. For complex rules, enter the expression manually. For examples, see Cron expressions.

      1. Click Use the build tool.

      2. In the pop-up list, select rules such as the time period and time, for example, to run the task at 3:00 every day, and then click OK. In the build tool, set the frequency to Daily, use the time picker to set the execution time to 03:00:00 (Hour: 3, Minute: 0, Second: 0), and then click OK.

      3. Click Validate Cron to view the 5 most recent trigger times for the rule. The generated cron expression is 0 0 3 * * ?. Click Verify cron to view the 5 most recent trigger times and confirm that the scheduling rule meets your expectations.

    3. Optional: In the Advanced Settings section, configure Time Offset, Time zone, Calendar, and Effective Time.

      The following table describes the advanced settings available for the Cron time type.

      Parameter

      Description

      Default

      Data Timestamp Offset

      The offset between the data time and the scheduled time. This value can be retrieved from the context during job execution.

      None

      Time zone

      Select a time zone based on your business needs. You can choose from common countries or regions, or use a standard GMT offset.

      None

      Calendar

      Schedule jobs based on a custom calendar. For example, use a calendar to run jobs only on business days.

      Daily

      Effective Time

      The date and time when the job schedule becomes active.

      Immediately