Unix question to find all the ruuning databases
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Unix question to find all the ruuning databases

Hybrid View

  1. #1
    Join Date
    Oct 2000
    Location
    Dallas:TX:USA
    Posts
    407
    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
    Rajeev Suri

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,095
    Use _ as your delimiter. Something like:
    ps -ef | grep ora_pmon | grep -v grep | awk -F_ '{ print $3 }'


    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  3. #3
    Join Date
    Oct 2000
    Location
    Dallas:TX:USA
    Posts
    407
    Interesting...no wonder why they say "Commonsense is very uncommon"

    Thanks Jeff, this is exactly what I was looking for !

    - Rajeev

    Rajeev Suri

  4. #4
    Join Date
    Dec 2000
    Posts
    126
    u can use this
    ps -ef|grep pmon|grep -v grep|cut -f 3 -d_

  5. #5
    Join Date
    Feb 2002
    Posts
    27
    ps -ef | grep ora_pmon_ | grep -v grep | awk '{if (NF==8) { print $8} else {print $9}}'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width