Solved

find session id from unix process id in oracle

Posted on 2008-06-20
2
11,480 Views
Last Modified: 2012-05-05
experts,

i ran one database script from os(unix) using nohup. i got unix process id. now i want to check the status of
my script in the database. how do i check it.

i want to find oracle session id based on this process id. how do i know this
0
Comment
Question by:pavan27
2 Comments
 
LVL 14

Expert Comment

by:ajexpert
ID: 21835427
I believe there is no connection between unix process id and oracle process id.
However, based on user id you and instance name you can get the info by querying v$session view
0
 
LVL 3

Accepted Solution

by:
MarkJBobak earned 500 total points
ID: 22174729
Well, first, which unix process id do you have?  Of your client program (i.e. SQL*Plus, Pro*C program, etc) or of your server process (i.e. oracle{your_ORACLE_SID} )??

If you have the client program pid, do:
ps -ef|grep pid, and look for a program that has that pid as the parent id.

Here's an example:
Here, my pid of my SQL*Plus session is 7306, so I do:
ps -ef|grep 7306
and I see this:
oracle    7306 30614  0 16:01 pts/3    00:00:00 sqlplus
oracle    7307  7306  0 16:01 ?        00:00:00 oracleinprd1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle    7440 31625  0 16:20 pts/3    00:00:00 grep 7306
oracle   31622  7306  0 16:15 pts/3    00:00:00 /bin/ksh -c sh


So, my server process is 7307.

Now, going to SQL*Plus, I can take that, and see the following:
  1* select vs.sid,vs.serial#,vs.username,vs.osuser,vs.machine,vs.program from v$session vs, v$process vp where vs.paddr = vp.addr and vp.spid = 7307
VMS@inprd1> /

       SID    SERIAL# USERNAME
---------- ---------- ------------------------------
OSUSER
------------------------------
MACHINE
----------------------------------------------------------------
PROGRAM
------------------------------------------------
       116      56847 VMS
oracle
rac01.prod.il.pqe
sqlplus@rac01.prod.il.pqe (TNS V1-V3)



So, v$process.spid is the background process, and it connects from v$process to v$session via v$process.addr=v$session.paddr.

Once you have the SID, you can look at V$SESSION, V$SESSION_WAIT, V$SESSTAT, etc, to monitor the session.

Hope that helps,

-Mark
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question