Updated on 2024-04-29 GMT+08:00

Natural Periodic Scheduling: Dependency on the Previous Period

Introduction

The natural periods for job scheduling can be classified into the following types: minute, hour, day, week, or month. Figure 1 lists the scheduling periods that can be configured for the dependency jobs of jobs with different scheduling periods.

Figure 1 Dependency between a job and that of the previous period

The scheduling of job A depends on the previous scheduling period of job B. The following scenarios are involved.

A Minute-Level Job Depends on Another Minute-Level Job

Rule: The minute is the minimum scheduling granularity, and there is no natural minute period. The dependency policy is to find the dependency instance of the job with a longer scheduling period in the previous scheduling period.

Example: Job A depends on job B. Job A is executed every 10 minutes, and job B is executed every 15 minutes, both starting from the 0th minute of each hour. Job A is executed after job B which starts from the 45th minute of the previous hour is complete.

A Minute-Level Job Depends on an Hourly Job

Rule: A minute-level job is executed after the previous job which is executed each calendar hour is complete.

Example: Minute-level job A depends on hour-level job B. Job A is triggered every 10 minutes, and job B is executed at the 18th minute of each hour. In this case, job A is executed at the 10th minute of the period.

A Minute-Level Job Depends on a Daily Job

Rule: A minute-level job depends on the previous period of the daily job and can be executed only after the previous daily job is executed.

Example: Job A depends on job B. Job A is executed every five minutes, and job B is executed at 02:30 every day. Job A depends on the instance of job B after 02:30 on the previous day.

An Hourly Job Depends on a Minute-Level Job

Rule: An hourly job depends on a minute-level job. All the minute-level job instances within the last natural hour are executed (excluding the start time of the previous hour and including the start time of the current hour).

Example 1: Job A is an hourly job and is executed at the 0th minute every hour. Job B is executed every 15 minutes. Job A depends on the instance of job B which is executed at the 45th minute in the previous hour.

Example 2: Job A is an hourly job starting at 03:20. Job B is executed every 15 minutes. Job A depends on the instance of job B generated at 03:15.

An Hourly Job Depends on Another Hourly Job

Rule: Instances in each calendar hour depend on each other. The range boundary is [00:00, 00:59]. The dependency policy is to find dependency instances from the previous scheduling period of a job with a long scheduling period.

Job A depends on job B. In the same calendar hour, job A is always executed after job B is executed in the previous period.

Example: Job A is executed at the fifth minute of each hour and job B is executed at the 12th minute. Job A depends on the instance generated in the previous hour at the fifth minute of each hour.

A job scheduled at a specified time point (discrete hour) depends on another job of this type:

  • On a calendar day, the number of upstream and downstream tasks in the dependency relationship is the same, and the number of upstream and downstream periods is also the same.
  • The number of upstream tasks is inconsistent with that of downstream tasks on a calendar day. A periodic instance generated on the day when a downstream task runs depends on the upstream instance that is closest to the scheduling time of the periodic instance. The periodic instance may depend on the upstream instances in an entire time range before the index or the nearest instance after the index.

An Hourly Job Depends on a Daily Job

Rule: An hourly job which depends on a daily job is executed only after the daily job is completed in the previous hour.

Example: Job A depends on job B. If job A is executed at the top of each hour, and job B is executed at 02:30, job A depends on the instance of job B at 02:30 on the previous day.

A Daily Job Depends on a Minute-Level Job

Rule: Instances of a daily job depend on the instances of all minute-level jobs on the previous day.

Example: Job A is a daily job and depends on job B (minute-level). Job A depends on the last instance of job B on the current day. Job A is executed after the last instance of job B is executed.

A Daily Job Depends on an Hourly Job

Rule: Instances of a daily job depend on the instances of an hourly job on the previous day.

Example: Job A is a daily job and depends on hourly job B. Job A depends on the instances of an hourly job in the last period of the previous day.

A Daily Job Depends on Another Daily Job

Rule: A job depends on the instance of the previous period of a job which is scheduled every calendar day. If job A depends on job B within the same calendar day, job A always depends on the instance of job B in the previous period regardless of the execution time configured for job A and job B. The day range is [00:00:00, 23:59:59].

Example: If job A is executed at 02:00 and job B is executed at 03:00, job A depends on the instance of job B executed at 03:00 in the previous period and is executed at 02:00 in the current period.

A Daily Job Depends on a Weekly Job

Rule: dependence on calendar days.

Example 1: Job A depends on job B. Job A is executed every day, and job B is executed every Wednesday. If the day before the day when job A is scheduled to be executed is not Wednesday, job B is not executed, and job A is directly executed.

Example 2: Job A depends on job B. Job A is executed every day, and job B is executed every Wednesday. If the day before the day when job A is scheduled to be executed is Wednesday, job B is executed, and job A is executed after job B is executed.

A Daily Job Depends on a Monthly Job

Rule: A daily job which depends on a monthly job is executed only after the monthly job is executed in the previous period .

Example: Job A depends on job B. Job A is executed once a day, and job B is executed once on the 15th day of each month. The execution of job A depends on the running instance of job B on the 15th day of the previous month.

A Weekly Job Depends on an Hourly Job

Rule: On a calendar day from 00:00 of the previous day (included) to 00:00 of the current day (excluded), the weekly job A is executed after all hourly tasks of job B are executed.

Example: Job A depends on job B. Job A is scheduled every Monday, and job B is executed at the 50th minute of each hour. Job A is executed after the last task of job B is executed at 23:50 on the last Sunday.

A Weekly Job Depends on a Daily Job

Rule: A weekly job can be executed only after the daily job of the previous day is complete.

Example: Job A depends on job B. Job A is executed once a day, and job B is executed once on every Monday of each month. The execution of job B depends on the running instances of job A on the previous day.

A Weekly Job Depends on Another Weekly Job

Rule: A weekly job which depends on a weekly job of the previous day can be executed only after the weekly job of the previous day is complete. If there is no instance for the previous day, no dependency is required.

Example: Job A depends on job B. Job A is executed once on every Monday, and job B is executed once on every Tuesday of each month. The execution of job B depends on the running instances of job A on Monday.

A Weekly Job Depends on a Monthly Job

Rule: dependence on calendar days.

Example 1: Job A depends on job B. Job A is executed every Wednesday, and job B is executed on the 10th day of each month. If the day before the day when job A is scheduled to be executed is the 10th day of a month, job A will be executed after job B is executed.

Example 2: Job A depends on job B. Job A is executed every Wednesday, and job B is executed on the 10th day of each month. If the previous day of the day when job A is scheduled to be executed is not the 10th day of a month, job A will be directly executed.

A Monthly Job Depends on a Daily Job

Rule: A monthly job can be executed only after the daily job of the previous day is complete.

Example: Job A depends on job B. Job B is executed once every day, and job A is executed once every month. The execution of job A depends on the running instances of job B on the previous day.

A Monthly Job Depends on a Weekly Job

Rule: dependence on calendar days.

Example 1: Job A depends on job B. Job A is executed on the 10th day of each month, and job B is executed every Wednesday. If the day before the day when job A is scheduled to be executed is not Wednesday, job B is not executed, and job A is directly executed.

Example 2: Job A depends on job B. Job A is executed on the 10th day of each month, and job B is executed every Wednesday. If the day before the day when job A is scheduled to be executed is Wednesday, job B is executed, and job A is executed after job B is executed.

A Monthly Job Depends on Another Monthly Job

Rule: dependence on calendar days.

Example 1: Job A depends on job B. Job A is executed on the first day of each month, and job B is executed on the second day of each month. On the first day of a month, job A is executed normally without being blocked by job B.

Example 2: Job A depends on job B. Job A is executed on the third day of each month, and job B is executed on the second day of each month. Job A can be executed after job B is executed on the second day of each month.

Example 3: Job A is executed on the third day of each month, and job B is executed on the second day of each month. Job A depends on job B.