Autosys作业执行跳过需求咨询:指定时间未满足条件则当日跳过次日正常执行
Let's break down how to implement this requirement—your job should run only within a defined daily time window, and if its prerequisites aren't met before the window starts, it skips that day's execution but resumes normally the next day. Here are two proven approaches I've used in production environments:
Approach 1: Prerequisite Check + Manual Skip Trigger
This method uses a pre-window check job to verify prerequisites, then triggers a skip if they're unmet.
Step 1: Define the Target Job
First, set up your core job with the time window and dependency condition. It will only run if the prereq is met and it's within the window:
insert_job: MY_DAILY_JOB job_type: CMD command: /opt/scripts/my_job_script.sh machine: prod-app-01 start_time: 09:00 end_time: 17:00 condition: s(PRE_REQ_JOB) # Only run if PRE_REQ_JOB succeeded run_calendar: STANDARD_WORKDAYS # Optional: restrict to workdays
Step 2: Add a Pre-Window Prerequisite Check
Create a job that runs 5-10 minutes before the window starts to check if the prerequisite is done. Use a custom script to validate the job status:
insert_job: CHECK_PREREQ_BEFORE_WINDOW job_type: CMD command: /opt/scripts/check_prereq_status.sh PRE_REQ_JOB machine: prod-app-01 start_time: 08:55 run_calendar: STANDARD_WORKDAYS exit_code: 0=SUCCESS, 1=FAILURE
The check_prereq_status.sh script can use autorep -J $1 -s to fetch the job's status, returning 0 if it succeeded, 1 otherwise.
Step 3: Trigger Skip if Prereq Fails
Create a job that runs right after the check, and sends a SKIP event to the target job if the check failed:
insert_job: SKIP_JOB_IF_PREREQ_MISSING job_type: CMD command: sendevent -E SKIP -J MY_DAILY_JOB machine: prod-app-01 start_time: 08:56 condition: f(CHECK_PREREQ_BEFORE_WINDOW) # Trigger only if check failed run_calendar: STANDARD_WORKDAYS
Why this works: If the prereq isn't completed by 08:55, the skip job marks MY_DAILY_JOB as SKIPPED for the day. Autosys won't attempt to run it again that day, but since it's a daily job, it will reset and check again the next morning automatically.
Approach 2: Box Job with Conditional Flow
For cleaner organization, wrap all logic in a box job that runs daily. This makes dependency management more intuitive:
insert_job: DAILY_JOB_BOX job_type: BOX machine: prod-app-01 start_time: 08:50 run_calendar: STANDARD_WORKDAYS # Inside the box: insert_job: CHECK_PREREQ job_type: CMD command: /opt/scripts/check_prereq_status.sh PRE_REQ_JOB machine: prod-app-01 box_name: DAILY_JOB_BOX exit_code: 0=SUCCESS,1=FAILURE insert_job: RUN_TARGET_JOB job_type: CMD command: /opt/scripts/my_job_script.sh machine: prod-app-01 box_name: DAILY_JOB_BOX start_time: 09:00 end_time: 17:00 condition: s(CHECK_PREREQ) insert_job: SKIP_TARGET_JOB job_type: CMD command: sendevent -E SKIP -J RUN_TARGET_JOB machine: prod-app-01 box_name: DAILY_JOB_BOX condition: f(CHECK_PREREQ)
Key Notes
- The
SKIPevent is critical here—it prevents the job from lingering in INACTIVE/WAITING state, which would block it from resetting the next day. - Always test the time window and condition logic in a non-production environment first to validate behavior.
- If using a run calendar, ensure it aligns with your daily execution schedule (e.g., exclude weekends/holidays if needed).
内容的提问来源于stack exchange,提问作者deepak_gj

