1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

How to check Oracle DB Status from Windows batch file

Discussion in 'General' started by kpagadala, Aug 6, 2009.

  1. kpagadala

    kpagadala Guest

    :confused:

    Hi Guys,

    Can you please tell me How to check Oracle DB Status from Windows batch file?.
    Its bit urgent for me.

    Thanks in Advance.

    Kishore
     
  2. tyro

    tyro Forum Genius

    Messages:
    368
    Likes Received:
    20
    Trophy Points:
    260
    Location:
    India
    Windows Batch file? Hmmm ok, i got this from another website. This batch code at the end checks any service status.

    Paste the script below into a text file with a .cmd extension. Customize the value of the service variable with the name of the Oracle service to check, as it appears in the Service name field of its Properties page in services.msc. Customize the value of the list variable with the location of a text file containing a list of the target computers, one per line (if you want to check many servers simultaneously). Customize the value of the log variable with the location of the log file to create.

    Running the script will query the target computers and, if the service is still running, write an entry to the log file. To instead check for services which are not running, change the value of the state variable to RUNNING.

    Code (Text):

    @echo off
    setlocal
     
    set service=w32time
    set state=STOPPED
    set list=computerlist.txt
    set log=servicelog.csv
     
    if not exist "%log%" echo Date,Time,Computer,%service% Status>"%log%"
     
    for /F %%G in ('type "%list%"') do (
     for /F "tokens=3 delims=: " %%H in ('sc \\%%G query "%service%" ^| findstr "        STATE"') do (
      if /I "%%H" NEQ "%state%" (
       echo %date%,%time%,%%G,%%H>>"%log%"
      )
     )
    )