JSI Tip 0888. General purpose scheduling routine.

I have scripted a genral purpose routine to allow a scheduled job to auto-repeat every n seconds and to terminate at a specific time.

JSISched.bat can be invoked by the Scheduler or submitted normally. The syntax is:

JSISched <Drive:>\<Folder>\batchfile.bat SleepSecs EHH EMM     where:

<Drive:>\<Folder>\batchfile.bat is the full path to the batch file you wish to repeat. It must not have an exit command.

SleepSecs is the number of seconds JSISched should wait after <Drive:>\<Folder>\batchfile.bat termination before resubmitting it.

EHH and EMM is the time (Hour and minute) that the batch should cease to be resubmitted.

Example: To schedule c:\tools\test.bat to run every 15 minutes ( 900 seconds ) on Monday, Tuesday, Wednesday, Thursaday, Friday, Saturday, and Sunday from 20:00 through 02:00 (date roll-over is automatically handled, when required):

AT 20:00 /EVERY:m,t,w,th,f,s,su cmd /c "JSISched c:\tools\test.bat 900 02 00"

JSISched.bat uses JSIToday, JSIDateM (amended 04-Dec-98), and JSITimeM (amended 04-Dec-98).

JSISched.bat contains:

@echo off
if exist %1 goto bok
@echo Syntax: JSISched <Drive:>\<Folder>\batchfile.bat SleepSecs EHH EMM
goto end
if not "%5"

"" goto syntax
if "%4"

"" goto syntax
set snooze="%2"
set snooze=%snooze:"0=%
set snooze=%snooze:"=%
set /a snooze=%snooze%
call JSITimeM %3 %4 + 00 00
set /a SSEC=%NSEC%
call JSIToday
set fin=%TDYY%%TDMM%%TDDD%%AHH%%AMM%
call JSITimeM
If %NSEC% LSS %SSEC% goto batch
call JSIDateM %TDYY% %TDMM% %TDDD% + 1
call JSITimeM %3 %4 + 00 00
set fin=%AYMD%%AHH%%AMM%
call %1
sleep %snooze%
call JSITimeM
call JSIToday
set now=%TDYY%%TDMM%%TDDD%%AHH%%AMM%
if "%now%" LSS "%fin%" goto batch
set SSEC=
set fin=
set now=
set snooze=

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.