none
Monotoring Execution for some time using scripts

    Pregunta

  • 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

    viernes, 17 de febrero de 2012 9:01

Respuestas

  • Although it is possible in batch files it would a lot easier to accomplish this by using vbscript.

    I pieced together this for you, perhaps not the most elegant solution but it should do the job. Place this at the start of your batch file:

    set HH=%TIME:~0,2%
    set MM=%TIME:~3,2%
    set /a MM=%MM% * 60
    set /a HH=%HH% * 3600
    set SS=%TIME:~6,2%
    Set /a start=%HH% + %MM% + %SS%

    And this at the end:

    set HH=%TIME:~0,2%
    set MM=%TIME:~3,2%
    set /a MM=%MM% * 60
    set /a HH=%HH% * 3600
    set SS=%TIME:~6,2%
    Set /a end=%HH% + %MM% + %SS%
    set /a totaltime=%end% - %start%
    if %totaltime% GTR 2100 (
    echo FAILURE > c:\logfile.log
    ) 


    viernes, 17 de febrero de 2012 9:46

Todas las respuestas

  • If you want to monitor the time your batch files take it is quite simple something like this would suffice:

    At the start of your batch file add this:

    echo Batch file started at: %time% >> c:\logfile.log

    At the end add this:

    echo Batch file finished at: %time% >> c:\logfile.log

    What this does it write a text to a log file containing the start and finish time for the batch files. Is this what you are looking for?



    viernes, 17 de febrero de 2012 9:30
  • 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

    viernes, 17 de febrero de 2012 9:35
  • May be it would sound a little stupid question but need to ask.

    Can we perform arithmatic operaations of time in batch files??


    Thanks, Mahesh

    viernes, 17 de febrero de 2012 9:36
  • Although it is possible in batch files it would a lot easier to accomplish this by using vbscript.

    I pieced together this for you, perhaps not the most elegant solution but it should do the job. Place this at the start of your batch file:

    set HH=%TIME:~0,2%
    set MM=%TIME:~3,2%
    set /a MM=%MM% * 60
    set /a HH=%HH% * 3600
    set SS=%TIME:~6,2%
    Set /a start=%HH% + %MM% + %SS%

    And this at the end:

    set HH=%TIME:~0,2%
    set MM=%TIME:~3,2%
    set /a MM=%MM% * 60
    set /a HH=%HH% * 3600
    set SS=%TIME:~6,2%
    Set /a end=%HH% + %MM% + %SS%
    set /a totaltime=%end% - %start%
    if %totaltime% GTR 2100 (
    echo FAILURE > c:\logfile.log
    ) 


    viernes, 17 de febrero de 2012 9:46
  • The examples I just posted was for your batch files. Sorry if I was unclear.
    • Marcado como respuesta Mahesh Birajdar viernes, 17 de febrero de 2012 10:20
    • Desmarcado como respuesta Mahesh Birajdar viernes, 17 de febrero de 2012 10:20
    viernes, 17 de febrero de 2012 10:12