AutoSys Workload Automation

 View Only

 Extended calendar logic

gdyrn's profile image
gdyrn posted Mar 17, 2025 10:12 AM

I have a user request for a calendar that I am having difficulty creating,

It is:  2 workdays before the 1st and 15th day of the month.   

This issue I have is in the mixing of workdays and days of the month in a single calendar. 

CARLOS JUPIA's profile image
CARLOS JUPIA

Please , take a look if this Solution Approach attend:

Since AutoSys does not natively support mixing absolute dates (1st and 15th) with workdays in a single calendar, we need to break this into two parts:

  1. Identify the two workdays before the 1st of each month.
  2. Identify the two workdays before the 15th of each month.
  3. Combine these conditions into a single calendar.

Step-by-Step Configuration

1. Create a Base Workday Calendar

This calendar should exclude weekends and company holidays:

  • Run the command:
    autocal_asc
    
  • Define a workday-based calendar (e.g., WORKDAYS_CAL) that marks only business days.

2. Create a Calendar for "Two Workdays Before the 1st"

  • First, create a calendar marking the 1st of each month:

    autocal_asc
    
    • Create a new calendar: FIRST_DAY
    • Manually mark the 1st day of each month.
  • Next, define a relative workday rule:

    autocal_asc
    
    • Create a new custom calendar: TWO_DAYS_BEFORE_1ST
    • Use the rule: "2 workdays before FIRST_DAY"
    • This will calculate the two previous workdays, skipping weekends/holidays.

3. Create a Calendar for "Two Workdays Before the 15th"

  • First, create a calendar marking the 15th of each month:

    autocal_asc
    
    • Create a new calendar: FIFTEENTH_DAY
    • Manually mark the 15th day of each month.
  • Then, define a relative workday rule:

    autocal_asc
    
    • Create a new calendar: TWO_DAYS_BEFORE_15TH
    • Use the rule: "2 workdays before FIFTEENTH_DAY"

4. Combine Both Calendars

Once you have TWO_DAYS_BEFORE_1ST and TWO_DAYS_BEFORE_15TH, you can create a final calendar that merges both:

autocal_asc
  • Create a new combined calendar: FINAL_CALENDAR
  • Use the command:
    combine TWO_DAYS_BEFORE_1ST TWO_DAYS_BEFORE_15TH
    
  • Save and exit.

5. Assign the Calendar to a Job

Now, when scheduling your job, assign it to FINAL_CALENDAR in the JIL definition:

insert_job: my_job
job_type: CMD
calendar: FINAL_CALENDAR
command: /path/to/script.sh

Verification

To check if the dates are correct:

autocal_asc -x FINAL_CALENDAR -Y 2025

This will show all execution dates for the calendar in 2025.


Conclusion

By separating the rules into multiple calendars and then combining them, you can effectively schedule jobs two workdays before the 1st and 15th of the month, avoiding weekends and holidays.

Michael Woods's profile image
Broadcom Employee Michael Woods

Hi,

I try to utilize extended calendars as much as possible to try and reduce the effort to generate the dates and future maintenance.  When I first looked at the problem, two working days before the 1rst of the month was pretty straight forward, by saying that it is the second to last workday of the month or keyword WORKM2.  Then I was looking at the 15th of the month and I have to admit it wasn't as obvious.  I started coming up with a chart of when it would be the 13th or 12, and so one.   UPDATE  I did some additional testing with holiday calendars and found some flaws in my original answer using the 9th workday of the month.  The update is below, but it is still not 100% if there is a holiday between the 15th and the second previous working day.  

extended_calendar: Community_Question
description: 
workday: mo,tu,we,th,fr
non_workday:  
holiday:  
holcal: 
cyccal: 
adjust: 0
condition: WORKDM2  | (MNTHD#13 ! (FRI|SAT)) | (MNTHD#12 & THU) | (MNTHD#11 & THU)

I have created an enhancement request to help make this easier.

Mike