Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

find session id from unix process id in oracle

Posted on 2008-06-20
Last Modified: 2012-05-05

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
Question by:pavan27
LVL 14

Expert Comment

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

Accepted Solution

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> /

---------- ---------- ------------------------------
       116      56847 VMS
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,


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.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

828 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