Cron

更新时间:
复制 MD 格式

Cron is a time-based job scheduler for Unix-like operating systems. You can use Cron to run cron jobs (commands or scripts) on a fixed schedule, such as at specific times or date intervals.

Important
  • The Professional Edition supports second-level scheduling with Cron.

  • The Basic Edition does not support second-level scheduling with Cron. Use the second_delay parameter instead.

Cron expression

A cron expression has the following format: second minute hour day of month month day of week [year]

The following table provides some common examples of cron expressions.

Cron expression

Description

0 */1 * * * ?

Triggers every minute.

0 0 5-15 * * ?

Triggers on the hour from 05:00 to 15:00 every day.

0 0/3 * * * ?

Triggers every 3 minutes.

0 0-5 14 * * ?

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

0 0/5 14 * * ?

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

0 0/5 14,18 * * ?

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

0 0/30 9-17 * * ?

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

0 0 10,14,16 * * ?

Triggers at 10:00, 14:00, and 16:00 every day.

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 Wednesdays in March.

0 15 10 ? * MON-FRI

Triggers at 10:15 every weekday.

0 0 23 L * ?

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

0 15 10 L * ?

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

0 15 10 ? * 6L

Triggers at 10:15 on the last Friday of each 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 each month from 2002 to 2005.

0 15 10 ? * 6#3

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

Cron scheduling configuration

This section explains how to configure Cron scheduling when creating a job. For complete instructions on job creation, see Create a job.

  1. Go to the Schedule Configuration tab. For more information, see Create a job.

  2. On the Schedule Configuration tab of the Create Task configuration wizard, configure the timing configuration parameters, and then click Next.

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

    2. Set the Cron Expression.

      Use the generation tool for simple scheduling rules. For complex rules that the tool cannot generate, enter the cron expression manually. For examples, see cron expression.

      1. Click Use Generator.

      2. In the dialog box that appears, select a time period and other rules. For example, to run a task at 3:00 every day, set the execution cycle to Every 1 day, use the scroll selector to set the execution time to 03:00:00, and then click OK to generate a cron expression.

      3. Click Validate Cron to view the last 5 trigger times. The generated cron expression is 0 0 3 * * ?. Click Validate Cron. The Last 5 Trigger Times list appears. After you confirm that the trigger times are as expected, click OK.

    3. Optional: In the Advanced Configuration section, set the Time Offset and Time Zone as needed.

      If you set Time type to cron, you can configure advanced settings. The following table describes the advanced settings for a job.

      Parameter

      Description

      Time offset

      The offset between the timestamp of the data to be processed and the time when the job is triggered. You can obtain the offset value from the context when SchedulerX runs a job.

      Time zone

      Select the time zone of a country or region or select a GMT time zone based on your business requirements.