need script for activate and deactivated databases in server

Hi all,

i am using below command to find the running datases, bases this command i need a (shell/korn)script for which databases are running and which databases are not running in one file. i need out put below format.

Kindly help to me. its very critical issue for me. i dont have script knowledge.

command : #ps -ef |grep pmon

databases
----------------

SREDEV1
SREDEV2
SREDEV3
SREDEV4
SREUAT2
SREUAT3
SREUAT4
SREUAT5
SREUAT6
SREUAT7
SREQA1
SREQA2
SREQA4
OREDEV1
COEDEV
REP_DB
MRTDEV1
RICDEV3A
RICPROD2
ODSUAT1
----------------------

OUTPUT

STGDEV1 RUNNING
STGDEV2 NOT RUNNING**
STGDEV3 RUNNING
STGDEV4 RUNNING
STGUAT2 NOT RUNNING
STGUAT3 NOT RUNNING
STGUAT4 NOT RUNNING
---------------------------------------------

THANKS & REGARDS
KRISHNA MURTHY

run following command

MYFILE=/home/sri/file
ps -elf | grep pmon > MYFILE # which finds for pmon patten copy to the file
for i in `cat $MYFILE`
do
     echo "$i - Running"
done

above script just shows running process.

if you want to automate for non-running process

  1. you have to create a file which should contain all processes.
  2. than compare all processes file to MYFILE(file) then you will get non-running processes.

thanks
srikanth

please help below concept.

i take two files with contents, now i want with using for loop the
first file contents check with second file all containts,if it is there
no need to print output, else print output in one file.

example

test1 test2 are two files with contents. i want to check test1 each containt check with test2 file each and every containts, if it is there no need to print otherwise print output in one file.

for this i need FOR loop script.

Thanks
murthy

Hi all,

take two files.

one file contains with total database list
second file contains with current running database list.(i will show the command in script)

#!/bin/bash

ps -ef |grep pmon |awk '{ print $8 $9 }'|cut -b10-|sed 's/mon_//' >/export/home/kmidatad/rundbs.txt
echo "RUNNING"
echo "================="
cat rundbs.txt
echo "================="
echo "TOTAL DATABASES ARE"
cat rundbs.txt|wc -l
echo "================="
echo "NOT RUNNING"
echo "================="
alldbsvar=`cat alldbs.txt`
rundbsvar=`cat rundbs.txt`
for i in $alldbsvar
do
a=0
for j in $rundbsvar
do
if [ $i = $j ]
then
a=1
# echo "aaa"
break
fi
done
if [ $a -eq 0 ]
then
echo $i
fi
done
echo "===================="
echo "process is completed"
echo "===================="

--------------------------------------
above example 1. alldbs.txt is the total database file
2. rundbs.txt is the current running database file.

thanks
Krishna murthy