?
Solved

find session id from unix process id in oracle

Posted on 2008-06-20
2
Medium Priority
?
11,945 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
[X]
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
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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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 syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

800 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