Starting Situation
- There are use cases for start time calculation that exceed the scope of run-time settings offered by JobScheduler:
- run a job each second first/last working day of a month, quarter or year:
- JobScheduler considers the second first/last day (not: working day).
- JobScheduler first counts the number of days for the specified period and then applies settings for non-working days. Some use cases require the opposite sequence.
- run a job every second day during a period of e.g. a month, quarter, year:
- JobScheduler re-calculates the run-time with the begin of a new day period at midnight.
- Individual periods for job starts that use a previous period for start time calculation cannot be used.
- run a job each second first/last working day of a month, quarter or year:
- The below use cases implement a workaround for a situation.when non-working days should be considered
- before counting for a number of first/last working days within a given period.
- for job starts that are repeated after a number of days, e.g. start a job every 3 days.
Use of included files for non-working days
- JobScheduler considers non-working days that can be specified by use of the JOE Job Editor.
- In addition non-working days can be configured by individual XML files that are included with a run-time of a job, order or schedule:
- any number of files can be specified.
- such files are specified with a relative path
- a setting
<include live_file="public_holidays.xml"/>
addresses a file in the current folder (relative path). - a setting
<include live_file="/globals/public_holidays.xml"/>
addresses a file in a./config/live/globals
(absolute path to thelive
folder). a setting
<include file="/tmp/globals/public_holidays.xml"/>
addresses a file in a/tmp/globals
folder (absolute path to the file system).
- a setting
The list of public holiday dates is provided with the public_holidays.xml file. Such a list of non-working dates is specific for a country or company and is created individually.
Use Cases
Start a job for the 2nd last working day of each month
- A working day is assumed for Mon-Fri, excluding Sat-Sun.
- The 2nd last working day is calculated excluding weekends and specific holiday dates as e.g. public holidays.
Cmdlet Execution
C:\PS> New-JobSchedulerHolidays -Select last -Days 2 -Interval month -NonWorkingWeekdays 6,7 -Force -FromDate '2016-01-01' -ToDate '2018-12-31' -HolidayFile ./public_holidays.xml -OutputFile ./some_order_holidays.xml
- The
New-JobSchedulerHolidays
cmdlet calculates the non-working days for the2nd
last
working day of eachmonth
within the specified date range (-FromDate
,-ToDate
). Saturday and Sunday are generally considered being non-working days (
-NonWorkingWeekdays 6,7
)The list of public holiday dates is provided with the public_holidays.xml file.
- By use of the
-Force
parameter all non-working days as specified by the-NonWorkingWeekdays
and-HolidayFiles
parameters are added to the output file. The list of complementary non-working days is created by the cmdlet with the output file some_order_holidays.xml. This list contains non-working days in addition to the above public holidays list and is calculated from the cmdlet parameters.
Order Configuration
To make an order use the list of complementary non-working days that is generated by the cmdlet the output file has to be included with the order like this:
Start a job for the 2nd working day of each month
- A working day is assumed for Mon-Fri, excluding Sat-Sun.
- The 2nd working day is calculated excluding weekends and specific holiday dates as e.g. public holidays.
Cmdlet Execution
C:\PS> New-JobSchedulerHolidays -Select first -Days 2 -Interval month -NonWorkingWeekdays 6,7 -Force -FromDate '2016-01-01' -ToDate '2018-12-31' -HolidayFile ./public_holidays.xml -OutputFile ./some_order_holidays.xml
- The
New-JobSchedulerHolidays
cmdlet calculates the non-working days for the2nd
working day of eachmonth
within the specified date range (-FromDate
,-ToDate
). Saturday and Sunday are generally considered being non-working days (
-NonWorkingWeekdays 6,7
).- By use of the
-Force
parameter all non-working days as specified by the-NonWorkingWeekdays
and-HolidayFiles
parameters are added to the output file. The list of complementary non-working days is created by the cmdlet with the output file. This list contains non-working days in addition to the above public holidays list and is calculated from the cmdlet parameters.
Order Configuration
To make an order use the list of complementary non-working days that is generated by the cmdlet the output file has to be included with the order like this:
Start a job for each 2nd working day of a year
- A working day is assumed for Mon-Fri, excluding Sat-Sun.
- The 2nd working day is calculated excluding weekends and specific holiday dates as e.g. public holidays.
Cmdlet Execution
C:\PS> New-JobSchedulerHolidays -Select next -Days 2 -Interval year -NonWorkingWeekdays 6,7 -Force -FromDate '2016-01-01' -ToDate '2016-12-31' -HolidayFile ./public_holidays.xml -OutputFile ./some_order_holidays.xml
The
New-JobSchedulerHolidays
cmdlet calculates the non-working days for each2nd
working day during a year within the specified date range (-FromDate
,-ToDate
).- By use of the
-Force
parameter all non-working days as specified by the-NonWorkingWeekdays
and-HolidayFiles
parameters are added to the output file. The list of complementary non-working days is created by the cmdlet with the output file. This list contains non-working days in addition to the above public holidays list and is calculated from the cmdlet parameters.
Order Configuration
To make an order use the list of complementary non-working days that is generated by the cmdlet the output file has to be included with the order like this:
Hints
How to check start times
- Start times can be visualized from the JOC GUI.
- In addition the
Show-JobSchedulerCalendar
andGet-JobSchedulerCalendar
cmdlets are available.
Cmdlet Execution
The cmdlet can be parameterized e.g. with the job chain for which start times should be calculated like this:
C:\PS> Show-JobSchedulerCalendar -JobChain /holidays/some_job_chain -ToDate 2016-12-31
The cmdlet calculates the next start times for the specified date range (
-FromDate
,-ToDate
). If no-FromDate
is specified then the current date is assumed.
Cmdlet Output
The sample output from the above cmdlet execution could look like this:
Sample cmdlet output for order start times________________________________________________________________________ Orders by start-time at 2016-08-29T03:00:00Z order some_order job chain /holidays/some_job_chain at 2016-09-28T03:00:00Z order some_order job chain /holidays/some_job_chain at 2016-10-29T03:00:00Z order some_order job chain /holidays/some_job_chain at 2016-11-28T04:00:00Z order some_order job chain /holidays/some_job_chain at 2016-12-30T04:00:00Z order some_order job chain /holidays/some_job_chain ________________________________________________________________________
How to generate complementary non-working days by a job
- The above use cases for the
New-JobSchedulerHolidays
cmdlet can be automated by use of- a PowerShell Job that runs with an Agent on the same server that the Master is operated for
- the PowerShell Command Line Interface
A sample job that creates complementary non-working days as explained with the above Start a job for each 2nd working day of a year chapter could look like this:
- This job parameterizes the
New-JobSchedulerHolidays
cmdlet to calculate complementary non-working days for one year starting from the date when the job starts. - The output file is written to the current job configuration folder, an existing file will be overwritten.
- Subsequently the start times for jobs and job chains in the current job configuration folder are displayed by use of the
Show-JobSchedulerCalendar
cmdlet.