LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-10-2008, 07:56 PM   #1
kais1
Member
 
Registered: Dec 2008
Posts: 61

Rep: Reputation: 17
script guidance needed


I have a script

#!/bin/sh
DATE1=`date +"%y""%m""%d""%H""%M"`
tmpfile=/tmp/KILL$DATE1.log
sqlplus system/manager<<EOF
set linesize 500
set pagesize 1000
set heading off
set feedback off
spool $tmpfile
select
'ALTER system kill session '''|| s.sid || ',' || s.serial# ||''';' Kill,'kill -9 '||p.spid "KILL OS PID"
from v\$session s,v\$process p where s.paddr=p.addr and s.status='INACTIVE'
spool off
EOF


which produces two columns of values like this :

ALTER system kill session '1663,6809'; kill -9 12018
ALTER system kill session '1731,7947'; kill -9 14073
ALTER system kill session '1921,52004'; kill -9 6066

Now, I want to take the first statement ALTER system kill session '1663,6809'; in sqlplus and run all the commands and after running th e same in oracle, I want to kill all the OS associated OS process using the 2nd column kill 09 12018 . how can I acheive this ?.. is there anyway I can modify the above script to take the output and kill the sessions at the database level and OS level?


please guide seniors ?


Kai
 
Old 12-11-2008, 06:01 AM   #2
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
Dear Friends,

Any updates


Kai
 
Old 12-11-2008, 07:13 AM   #3
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

you can run both commands from within sqlplus.
You have to set a ! in front of the OS command.
This looks like:
ALTER system kill session '1663,6809'; !kill -9 12018

Both can be executed by changing your script this way, that it will execute $tempfile at the end.

This should look like this:
-------------begin---------------------------------------
#!/bin/sh
DATE1=`date +"%y""%m""%d""%H""%M"`
tmpfile=/tmp/KILL$DATE1.log
sqlplus system/manager<<EOF
set linesize 500
set pagesize 1000
set heading off
set feedback off
spool $tmpfile
select
'ALTER system kill session '''|| s.sid || ',' || s.serial# ||''';' Kill,'!kill -9 '||p.spid "KILL OS PID"
from v\$session s,v\$process p where s.paddr=p.addr and s.status='INACTIVE'
spool off
@$tmpfile
EOF
--------------------end--------------
 
1 members found this post helpful.
Old 12-11-2008, 09:38 AM   #4
kais1
Member
 
Registered: Dec 2008
Posts: 61

Original Poster
Rep: Reputation: 17
Hai pal,

am getting error



SQL> ALTER system kill session '1764,60569'; ! kill -9 12151
2 /
ALTER system kill session '1764,60569'; ! kill -9 12151
*
ERROR at line 1:
ORA-00911: invalid character



kai
 
Old 12-12-2008, 08:13 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Please, put your code in "Code:" blocks, i.e. put it inside [CODE][/CODE] tags.
 
  


Reply


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
slackbuild guidance needed mcnalu Slackware 10 05-11-2008 11:07 AM
Adding a second linux. [Guidance needed] Zmyrgel Linux - Newbie 20 01-29-2006 07:49 AM
guidance needed please with java runtime ceborame Ubuntu 2 08-18-2005 01:49 PM
Guidance Needed! LinuxRam Linux - Certification 5 09-07-2004 10:06 PM
Guidance needed: running an application on startup. nyumedic2000 Linux - General 1 07-15-2004 04:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:12 AM.

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