script to check DB status using windows batch/cmd file
Posted by Pavan DBA on October 16, 2011
@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%”
)
)
)
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.
Chandra said
Thanks Pavan. Regards,Chandra