-
Hi,
On a particular HP-UX 11 server, I need a list of all the Oracle databases "running".
I can look at the /etc/oratab file but it will include ALL the databases (including the ones not running)
the following command gives me the list of Oracle Process Monitors (PMON) running --
ps -ef | grep ora_pmon_ | grep -v grep
The output is as following --
oracle 2410 1 0 Dec 3 ? 12:44 ora_pmon_TEST
oracle 2461 1 0 Dec 3 ? 10:25 ora_pmon_DEV
oracle 29986 1 0 00:05:41 ? 0:04 ora_pmon_PROD
oracle 264 1 0 00:06:51 ? 0:04 ora_pmon_QC
After that I should be able to use AWK to get the last column (column 8) and filter out the "ora_pmon_" string to get the SID of the running databases --
So the following command should do the trick -
$ps -ef | grep ora_pmon | grep -v grep | awk '{ print $8 }' | sed 's/ora_pmon_//' | grep -v sed
But the output is --
12:44
10:25
DW
BO40
That means that in first 2 records, the 8th column is time while in the last 2 records it is the process name.
As per the "man" pages on "ps", column 8 should be the "args" column meaning it should give me the process name (ora_pmon_ etc.)
Any suggestions ?
Thanks,
- Rajeev
-
Use _ as your delimiter. Something like:
ps -ef | grep ora_pmon | grep -v grep | awk -F_ '{ print $3 }'
-
Interesting...no wonder why they say "Commonsense is very uncommon"
Thanks Jeff, this is exactly what I was looking for !
- Rajeev
-
u can use this
ps -ef|grep pmon|grep -v grep|cut -f 3 -d_
-
ps -ef | grep ora_pmon_ | grep -v grep | awk '{if (NF==8) { print $8} else {print $9}}'