JSI Tip 1364. Prevent scheduled jobs from running on a holiday.
June 3, 1999
If you wish to prevent scheduled jobs from running on a holiday, add:
call holiday
if "%holiday%"
"Y" exit
OR
call holiday
if "%holiday%""Y" go to endlabel
to the beginning of your batch jobs.
Place holiday.dat, containing the holiday dates, in the folder that your scheduled jobs start in. To determine the starting folder:
AT HH:MM /interactive cmd /k
where HH:MM is two minutes from now. When the command prompt opens, you will see the folder. You can also change holiday.dat in holiday.bat to Folderholiday.dat .
To determine the format of the date in holiday.dat, type:
date /t
On JSI's computers, it returns:
DayOfWeek MM/DD/YYYY
Add as many dates (MM/DD/YYYY) to holiday.dat as you wish. Don't forget to remove old dates and add new ones each year.
Set permissions on holiday.dat so that you have Full Control and the Schedule service account has Read.
Place holiday.bat in the %PATH%. Holiday.bat contains:
@echo offsetlocalfor /f "tokens=1* delims=/ " %%i in ('date /t') do set today="%%j"set today=%today: =%set holiday=Nfor /f "Tokens=*" %%i in (holiday.dat) do call :test "%%i"endlocal&set holiday=%holiday%goto end:testset fdate=%1set fdate=%fdate: =%if %fdate% EQU %today% set holiday=Y:end
About the Author
You May Also Like