Schedule Job for Selected day of Selected Month

Community Alums
Not applicable

Hi All,

I have a requirement for scheduled jobs to run on the on a certain day on certain months, for example -

Run on 1st of March, June, September and December.

Is there a conditional script to achieve this and to miss out weekends?

Many thanks,

Alex

 

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

Set your scheduled job to run Monthly, on the date you need and time. Then in the condition script check for the month to trigger. Example below script triggers on 1 month, 4 month, etc

find_real_file.png

 

 

var result = false;
var gdt = new GlideDateTime();
if (gdt.getMonthLocalTime() == 1 || gdt.getMonthLocalTime() == 4 || gdt.getMonthLocalTime() == 7 || gdt.getMonthLocalTime() == 10) {
	result = true;
}
result;

View solution in original post

10 REPLIES 10

Michael Fry1
Kilo Patron

Set your scheduled job to run Monthly, on the date you need and time. Then in the condition script check for the month to trigger. Example below script triggers on 1 month, 4 month, etc

find_real_file.png

 

 

var result = false;
var gdt = new GlideDateTime();
if (gdt.getMonthLocalTime() == 1 || gdt.getMonthLocalTime() == 4 || gdt.getMonthLocalTime() == 7 || gdt.getMonthLocalTime() == 10) {
	result = true;
}
result;

Community Alums
Not applicable

Hi Michael,

 

Thank you!

 

I have set this now and will confirm this worked correctly tomorrow, 1st day of 10th month.

 

Thanks again,

Alex

If I am not mistaken, this will only run on the 1st of the month. If the 1st falls on a weekend, then this should not run on that day, but wait until Monday.

Ah yes, nice catch! Alex, this will not exclude weekends, missed that in your original post!

Community Alums
Not applicable

Hi Michael,

 

This has worked!  I double checked with the team that requested this and skipping weekends was not actually required.

 

Thanks again!

Alex