Review your favorite Linux distribution.
Go Back > Forums > Other *NIX Forums > AIX
User Name
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.


  Search this Thread
Old 07-10-2012, 03:46 AM   #1
Registered: Oct 2005
Location: Bangladesh
Posts: 471

Rep: Reputation: 30
Killing oracle user process from OS directly !

I am using Oracle 10g on AIX 6.1 . I want to kill the oracle session who are already INACTIVE for the last 25 minutes.
For this reason I run the below query :

select 'kill -9 '||spid " " from v$process where addr in(
select paddr from v$session where program like 'frm%'and status='INACTIVE'and last_call_et>1500

The output will come like below :

kill -9 167547
kill -9 182974

Now here I need to run the 'kill' command manually .

But I want to run the above two procedures using One script in Linux/AIx environment . so that I can kill the user process
from the OS directly .

Would any experts will help me regarding this issue .. ..

Waiting for kind reply ... ...
Old 07-10-2012, 05:26 AM   #2
Registered: Jan 2012
Location: South Africa
Posts: 333

Rep: Reputation: 131Reputation: 131
Hi there,

Firstly I must say that killing Oracle processes in this way is probably not the best approach to take. Secondly, if you must kill these (or any other) processes from the OS, it's always best to try "kill -15" first, to give the process a chance to handle the request gracefully. "kill -9" should only be used in extreme cases, after trying "kill -15".

If you must kill processes in this way, you could run your SQL query via sqlplus in a script, and either redirect the output to a new script, pipe the output to a loop and run the commands one by one, or put xargs to work.

Using the xargs approach, try these steps:
* It's probably easiest to put the SQL into a separate file, say staleprocesses.sql.
* Change the query to select on the PID, without prepending the "kill -9".
* You'll need to set some options to not show unnecessary information, which I'm afraid I can't help you with - haven't used sqlplus in years.
* Run the query as follows, and check that it outputs ONLY the process ids:
sqlplus username/password @staleprocesses.sql
* Once this works, run the following to actually kill the processes:
sqlplus username/password @staleprocesses.sql | xrags kill -9
I hope this helps to get you going on a solution.
Old 07-11-2012, 01:49 PM   #3
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Any reason you can't use the alter command within Oracle?



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
killng parent process without killing child process (Linux C programming) Linux - Newbie 3 07-24-2015 09:37 AM
Killing More than one process ruud Programming 11 04-27-2010 07:30 AM
LXer: Is Oracle Quietly Killing OpenOffice? LXer Syndicated Linux News 1 04-14-2010 04:10 AM
Killing a process by its name rabeea Linux - Networking 3 03-17-2005 06:30 AM
Really Killing a Process! lazlow69 Linux - Newbie 14 05-10-2003 11:31 PM

All times are GMT -5. The time now is 02:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration