Pavan DBA's Blog

The DBA Knowledge Store

script to check DB status using windows batch/cmd file

Posted by Pavan DBA on October 16, 2011

@echo off

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%”

paste the above code in notepad and save it as .cmd file. chage the value of service with oracle service name, log to the location you required and also provide the list of instances to check.


One Response to “script to check DB status using windows batch/cmd file”

  1. Chandra said

    Thanks Pavan. Regards,Chandra

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: