Monotoring Execution for some time using scripts

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Maheshgx
Posts: 2
Joined: 17 Feb 2012 02:41

Monotoring Execution for some time using scripts

#1 Post by Maheshgx » 17 Feb 2012 02:59

Hi,
I am new to the world of scripting area.
I have a scenario in Which i am writing script in which call other .bat scripts which usually takes 26 minutes for execution.
What i want to do is like i want to monitor them.
Say if it takes 26 minutes to execute then i want to create a scripts which will set start time for each batch file that is executing and will give some time frame like 35 minutes.
If it do complete its execution in 35 minutes the it should send some message sat it should create a file.
Can it be achieved using DOS scripts.
My OS is Windows Server 2003 R2 x64 edition.
How it can be done?
Which commands can be used ?

Thanks,
Mahesh

Maheshgx
Posts: 2
Joined: 17 Feb 2012 02:41

Re: Monotoring Execution for some time using scripts

#2 Post by Maheshgx » 17 Feb 2012 04:10

Hi,

I have following script.

REM @echo off
set USER=dev_odi_repo
set PASSWORD=bridge125
set DB=OMPODIT

SET WORK_BASE=D:\oracle\product\11.1.1\Oracle_ODI_1\oracledi\agent\bin
set LOGDIR=%WORK_BASE%\scripts\work3
set TEMPDIR=%WORK_BASE%\scripts\temp3
set SQLDIR=%WORK_BASE%\scripts

set ORACLE_HOME=D:\oracle\product\11.2.0\dbhome_1

call %WORK_BASE%\odi_pkg_tata_master_omp.bat
call %WORK_BASE%\odi_pkg_bur_master_omp.bat
call %WORK_BASE%\odi_pkg_bet_master_omp.bat
call %WORK_BASE%\odi_pkg_bar_master_omp.bat
call %WORK_BASE%\odi_pkg_poz_master_omp.bat

CALL %WORK_BASE%\scripts\transformation_master_omp.bat

Now i want to set a start time for execution of call %WORK_BASE%\odi_pkg_tata_master_omp.bat and need to check if its been completed in 35 minuts.

If yes the nsame thing for next one . It will go as of it till the last file.

And if i encounter that its running for more than 35 minutes then it should be write say FAILURE in some text file.

Can it be achieved ?

Thanks, Mahesh

Aacini
Expert
Posts: 1930
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Monotoring Execution for some time using scripts

#3 Post by Aacini » 18 Feb 2012 13:51

Code: Select all

for /F "tokens=1,2 delims=:" %%a in ("%time%") do set /A "baseTimePlus35=((1%%a %% 100)*60)+%%b+35"
call %WORK_BASE%\odi_pkg_tata_master_omp.bat
call :CheckLapse
call %WORK_BASE%\odi_pkg_bur_master_omp.bat
call :CheckLapse
call %WORK_BASE%\odi_pkg_bet_master_omp.bat
call :CheckLapse
call %WORK_BASE%\odi_pkg_bar_master_omp.bat
call :CheckLapse
call %WORK_BASE%\odi_pkg_poz_master_omp.bat
call :CheckLapse

rem Etc...


:CheckLapse
for /F "tokens=1,2 delims=:" %%a in ("%time%") do set /A "timeNow=((1%%a %% 100)*60)+%%b"
if %timeNow% gtr %baseTimePlus35% echo FAILURE > someFile.txt
set /A baseTimePlus35=timeNow+35"
exit /B


Previous code must include the day if the 35 minute lapse may pass over midnight. If you need it, please request it.

aGerman
Expert
Posts: 4740
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Monotoring Execution for some time using scripts

#4 Post by aGerman » 18 Feb 2012 14:51

Also see the date and time functions on this site:
http://www.commandline.co.uk/lib/treeview/index.php

Regards
aGerman

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Monotoring Execution for some time using scripts

#5 Post by foxidrive » 18 Feb 2012 21:01

My interpretation of the task is: time a routine and if it is still running after 35 minutes then echo an alert.


I assume the OP then wants the task killed and to continue with the next task in the list, but maybe not.


The solution above is asynchronous and will wait for each task to complete before continuing.

Aacini
Expert
Posts: 1930
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Monotoring Execution for some time using scripts

#6 Post by Aacini » 18 Feb 2012 21:38

Maheshgx wrote:Now i want to set a start time for execution of call %WORK_BASE%\odi_pkg_tata_master_omp.bat and need to check if its been completed in 35 minuts.

If yes the nsame thing for next one . It will go as of it till the last file.

And if i encounter that its running for more than 35 minutes then it should be write say FAILURE in some text file...

I think these words are clear enough that they do not require interpretations or assumptions...

However, I may be wrong and you may be right, but if this is the case; where is your synchronous solution to this problem? Otherwise I don't understand the purpose of your post... :(

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Monotoring Execution for some time using scripts

#7 Post by foxidrive » 18 Feb 2012 21:54

Aacini wrote: Otherwise I don't understand the purpose of your post... :(


I think I was quite clear. You'll have to wait for acknowledgement from the OP before you know if your interpretation is right.

Aacini
Expert
Posts: 1930
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Monotoring Execution for some time using scripts

#8 Post by Aacini » 19 Feb 2012 16:18

I read this topic and posted a solution with the objective to help the OP.

I have no doubts about the original request. If I would had questions on the task to solve, it is customary to ask the OP to clear they before even try to think about a solution. Didn't know you this? :?


foxidrive wrote:You'll have to wait for acknowledgement from the OP before you know if your interpretation is right.

Are you trying to state that I must remain waiting for OP's acknowledgment before I get satisfied with my answer because YOU have a different interpretation of the question? :lol: :lol: :lol:


If the OP indicate he wants the synchronous solution instead I will not worry, I will just try to solve it...

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Monotoring Execution for some time using scripts

#9 Post by foxidrive » 19 Feb 2012 19:29

Are your pants on backward today? Something is irritating you out of all proportion to my post...

Aacini
Expert
Posts: 1930
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Monotoring Execution for some time using scripts

#10 Post by Aacini » 20 Feb 2012 00:13

Well, let me explain myself...

When a question have a valid answer already it is not common that an additional post criticize the first answer, unless of course that the second post fix an error, or present a different solution, or propose any constructive criticism. However your first post does not contain anyone of these cases, but it is a pure negative criticism on my answer. Note that you had not used any affable term (like "I think", "perhaps", "it would", etc) in your post.

I read your first post and, confused, asked you for its purpose, but your reply was "quite clear": another pure and simple criticism to my answer.

If you still don't see my viewpoint, let me do it clearer. Your first two posts above have this meaning for me:

foxidrive's two posts meaning for me wrote:"My interpretation of the task is" different than yours (but I not present the solution I proposed, just personal opinions). "Your solution above" is not what "I assumed the OP wants", so "you'll have to wait for acknowledgement from the OP".

Of course, I get offended because these words...

Perhaps I misunderstood something?

Post Reply