Solved

find session id from unix process id in oracle

Posted on 2008-06-20
2
11,136 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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 explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now