Updated on 2024-11-12 GMT+08:00

Natural Periodic Scheduling: Same-Period Dependency

Introduction

Job A depends on Job B which has the same scheduling period as job A. The period unit can be 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 jobs with the same period

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 in the previous scheduling period.

Example 1: Job A and job B have the same scheduling period (minutes), and A depends on B. At the same time point, A is executed after B is executed.

Figure 2 A minute-level job depends on another minute-level job (example 1)

Example 2: Job A depends on job B. The scheduling period of job A is 15 minutes, and that of job B is 10 minutes. Job A depends on the job B instances within 15 minutes before job A's execution (including the current hour). The job A executed at 02:15 depends on a job B instance (executed at 02:10), and the job A executed at 02:30 depends on two job B instances (executed at 02:20 and 02:30, respectively). The boundary range is (0 minutes,15 minutes].

Figure 3 A minute-level job depends on another minute-level job (example 2)

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 hourly job B. Job A is triggered every 10 minutes, and job B is executed at the 16th minute of each hour. In this case, job A is executed after job B is executed in the previous period.

Figure 4 A minute-level job depends on an hourly job

A Minute-Level Job Depends on a Daily Job

Rule: A minute-level job which depends on a daily job is executed only after the daily job is executed.

Example: Job A depends on job B. Job A is executed every 30 minutes, and job B is executed at 22:45. All the instances of job A before 22:45 will be executed after job B is executed.

Figure 5 A minute-level job depends on a daily job

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 The range is (2:00,3:00].

Example 1: Job A depends on job B. Job A is an hourly job and is executed at the top of each hour. Job B is executed every 15 minutes. After job B is executed, job A is executed. Job A depends on the instances of job B within an hour. For example, job A executed at 03:00 depends on four instances of job B, which are generated at 02:15, 02:30, 02:45, and 03:00, respectively.

Figure 6 An hourly job depends on a minute-level job (example 1)
  • If you select Recent when configuring job dependency, the hourly job depends only on the latest running instance of the selected job. For example, if job A starts at 03:00, it depends on the instance of job B which is executed at 02:45.
  • If job A is scheduled at 00:00, it can depend on job B which is a minute-level job of yesterday.

An Hourly Job Depends on Another Hourly Job

Rule: Instances in each calendar hour depend on each other. The range boundary is the calendar hour [00:00, 00:59].

Example 1: Job A depends on job B. In the same calendar hour, job A is always executed after job B regardless of when they are executed.

Figure 7 An hourly job depends on another hourly job (example 1)

Example 2: Job A depends on job B. Job A is executed at the fifth minute of each hour, and job B is executed at the 12th minute of each hour. A is executed after B is executed.

Figure 8 An hourly job depends on another hourly job (example 2)

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 executed.

Example: Job A depends on job B. Job A is executed at the top of each hour, and job B is executed at 02:30. All the instances of job A before 02:30 will be executed after job B is executed.

Figure 9 An hourly job depends on a daily job

A Daily Job Depends on a Minute-Level Job

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

Example: Job A is a daily job and is scheduled at 22:00 every day. It depends on job B which is scheduled every 30 minutes. Job A depends on all instances of job B on a calendar day. Job A is executed after the last instance of job B is executed.

Figure 10 A daily job depends on a minute-level job

If you select Recent when configuring job dependency, the daily job depends only on the latest running instance of the selected job. For example, if job A is scheduled at 22:00 every day, it depends on the instance of job B which is executed at 21:30.

A Daily Job Depends on an Hourly Job

Rule: Instances of a daily job depend on the instances of all hourly jobs within a day. Job A is a daily job and depends on job B. Job A depends on all instances of job B on a calendar day. Job A is executed after the last instance of job B is executed.

Example: Job A depends on job B. If job A is scheduled at 17:00 every day and job B is executed every five hours starting from 00:00, job A is executed after the instance of job B is executed at 20:00.

Figure 11 A daily job depends on an hourly job

If you select Recent when configuring job dependency, the daily job depends only on the latest running instance of the selected job. For example, if job A is scheduled at 17:00 every day, it depends on the instance of job B which is executed at 15:00.

A Daily Job Depends on Another Daily Job

Rule: Jobs depend only on instances on the same calendar day. If job A depends on job B within the same calendar day, job A is always executed after job B regardless of their execution time. The day range is [00:00:00,23:59:59].

Example 1: Job A depends on job B. Job A is executed at 02:00, and job B is executed at 03:00. Job A is executed after job B is executed at 03:00.

Figure 12 A daily job depends on another daily job (example 1)

Example 2: Job A depends on job B. Job A is executed at 05:00, and job B is executed at 03:00. Job A is executed at 05:00 after job B is executed.

Figure 13 A daily job depends on another daily job (example 2)

A Daily Job Depends on a Weekly Job

Rule: A daily job depends on a weekly job which is executed on the current day. If the weekly job is not executed on the current day, the daily job is executed directly. If the weekly job is executed on the current day, the daily job will be executed after the weekly job is executed.

Example 1: Job A depends on job B. Job A is executed every day, and job B is executed every Wednesday. If 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 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 depends on a monthly job executed on the current day. If the monthly job is not executed on the current day, the daily job is directly executed. If the monthly job is executed on the current day, the daily job will be executed after the monthly job is executed.

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. If the current day is not the 15th day, job B is not executed, no instance is generated for job B, and job A is directly executed. If the current day is the 15th day, job A will be executed after job B is executed.

Figure 14 A daily job depends on a monthly job

A Weekly Job Depends on an Hourly Job

Rule: On a calendar day from 00:00:00 (included) to 23:59:59 (excluded), weekly job A is executed after all the tasks of hourly 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 waits until the last task of job B is executed at 23:50 on Monday. Job A depends on all the instances of job B on Monday.

A Weekly Job Depends on a Daily Job

Rule: Weekly jobs depend only on jobs scheduled and executed on the same day.

Example: Job A depends on job B. Job A is scheduled to be executed on Tuesday, and job B is executed every day. On Tuesday, Job A is executed after job B is executed.

Figure 15 A weekly job depends on a daily job

A Weekly Job Depends on Another Weekly Job

Rule: Weekly jobs depend only on job instances scheduled and executed on the same day.

Example 1: Job A depends on job B. Job A is scheduled to be executed on Tuesday, and job B is scheduled to be executed on Wednesday. Job A is executed on Tuesday rather than on Wednesday after job B is executed.

Figure 16 A weekly job depends on another weekly job (example 1)

Example 2: Job A and job B are both executed on Tuesday, and Job A depends on job B. Job A is executed after job B is executed.

Figure 17 A weekly job depends on another weekly job (example 2)

A Weekly Job Depends on a Monthly Job

Rule: A weekly job depends on a monthly job which is executed on a calendar day. If the monthly job is not executed on the current day, the weekly job is executed directly. If the monthly job is executed on the current day, the weekly job will be executed after the monthly job is executed.

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 job A is scheduled to be executed on 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 job A is not scheduled to be executed on 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 as long as the current daily job is complete.

Example: Job A is a monthly job and depends on job B which is a daily job. Job A is executed after job B is executed on the day when job A is scheduled to be executed.

Figure 18 A monthly job depends on a daily job

A Monthly Job Depends on a Weekly Job

Rule: A monthly job depends on a weekly job which is executed on the day when the monthly job is scheduled to be executed. If the weekly job is not executed on that day, the monthly job is executed directly. If the weekly job is executed on that day, the monthly job will be executed after the weekly job is executed.

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 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 when job A is scheduled to be executed is Wednesday, job A is executed after job B is executed.

A Monthly Job Depends on Another Monthly Job

Rule: A monthly job depends on another monthly job which is executed on the day when the former monthly job is scheduled to be executed. If the depended monthly job is executed after the dependent job, the dependent job is executed properly. Except that, the dependency relationship works.

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 and job B are both executed on the second day of each month. Job A depends on the instance that is generated after job B is executed.

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.