terminating a batch file after 10 minutes
terminating a batch file after 10 minutes
Author
Discussion

ProPlus

Original Poster:

3,810 posts

271 months

Tuesday 3rd July 2007
quotequote all
I have a batchfile.... schedule.bat

@echo off
setlocal
REM This batch file runs the IBCom Scheduler Process.
REM It assumes it is being run from the directory in which it resides and that
REM the environment variable JAVA_HOME is defined.

if 1%JAVA_HOME% == 1 goto NO_JAVA_HOME

set _LIBJARS=
for %%i in (lib\*.jar) do call helper\cpappend.bat %%i

%JAVA_HOME%/bin/java -cp ".;./properties;%_LIBJARS%" -Dlog4j.configuration=./properties/Scheduler.properties com.hsbcib.securities.ibcomapps.schedule.Scheduler %1 %2 %3
goto END

:NO_JAVA_HOME
echo Environment variable JAVA_HOME is not set; should be something like C:\tools\jdk1.3.1
goto END

:END
endlocal

==========



problem being it calls a jar file that I cant access.... at the above will run indefinately.

I tried a schedule task that starts up and was supposed to terminate after 10mins and then 20mins later do the process agin.

That didn't work..... All it did was keep opening multiple copies of the above bat file.

I need to find a way for a scheduled task to start the above bat file, let it run for 10mins, kill the bat file and then do the whole process again 20 mins later... any ideas?

Cheers in advance.

Si

FunkyGibbon

3,864 posts

295 months

Tuesday 3rd July 2007
quotequote all
I've used pskill.exe (from the windows resource kit) to effect this kind of thing.

http://www.microsoft.com/technet/sysinternals/util...

schedule pskill to kill the schedule.bat every 10 mins and schedule schedule.bat whenever you like to restart.

klunky bit it should work

The Griffalo

72,863 posts

270 months

Tuesday 3rd July 2007
quotequote all
Should tell you all you need to know biggrin

http://malektips.com/xp_dos_0002.html

You can download the tools to get the sleep command or use the old ping timer trick.

As for it not terminating, can you include some errorlevel processing to decide if the command ran successfully and fall gracefully out the bottom?


ProPlus

Original Poster:

3,810 posts

271 months

Tuesday 3rd July 2007
quotequote all
FunkyGibbon said:
I've used pskill.exe (from the windows resource kit) to effect this kind of thing.

http://www.microsoft.com/technet/sysinternals/util...

schedule pskill to kill the schedule.bat every 10 mins and schedule schedule.bat whenever you like to restart.

klunky bit it should work
Is that on the Windows Server 2003?

Got a quick exmaple of its use?


Edited by ProPlus on Tuesday 3rd July 15:57

ProPlus

Original Poster:

3,810 posts

271 months

Tuesday 3rd July 2007
quotequote all
The Griffalo said:
Should tell you all you need to know biggrin

http://malektips.com/xp_dos_0002.html

You can download the tools to get the sleep command or use the old ping timer trick.

As for it not terminating, can you include some errorlevel processing to decide if the command ran successfully and fall gracefully out the bottom?
Problem is the Java call in the batch file, meaning as soon as it hits that, it aint ever coming out till an external influence shuts down the scheduler.bat

Hence the need to kill somehow after 10 mins

The Griffalo

72,863 posts

270 months

Tuesday 3rd July 2007
quotequote all
Pskill as above should nuke it succesfully.

SneakyNeil

9,296 posts

268 months

Tuesday 3rd July 2007
quotequote all
ProPlus said:
problem being it calls a jar file that I cant access.... at the above will run indefinately.
How about a check to see if you can access the file first, that will fail gracefully - something like copying it to null then an if errorlevel... goto type affair.

selwonk

2,143 posts

256 months

Tuesday 3rd July 2007
quotequote all
Yep - I'd go with PSkill too. All the SysInternals stuff now taken over by MS are spot on...

FunkyGibbon

3,864 posts

295 months

Tuesday 3rd July 2007
quotequote all
ProPlus said:
FunkyGibbon said:
I've used pskill.exe (from the windows resource kit) to effect this kind of thing.

http://www.microsoft.com/technet/sysinternals/util...

schedule pskill to kill the schedule.bat every 10 mins and schedule schedule.bat whenever you like to restart.

klunky bit it should work
Is that on the Windows Server 2003?

Got a quick exmaple of its use?


Edited by ProPlus on Tuesday 3rd July 15:57
you can download it from that URL above, and it shows you the syntax as well

basically:

pskill.exe processname

where processname is the name of the java app running (probably just java.exe) but check in task manager as to what processes run when you start your schedule.bat file and then use pskill to nuke them

GreenV8S

31,027 posts

315 months

Tuesday 3rd July 2007
quotequote all
You could do all that process launching / timing out quite easily with jscript.