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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-10-2008, 07:56 PM
|
#1
|
|
Member
Registered: Dec 2008
Posts: 61
Rep:
|
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
|
|
|
|
12-11-2008, 06:01 AM
|
#2
|
|
Member
Registered: Dec 2008
Posts: 61
Original Poster
Rep:
|
Dear Friends,
Any updates
Kai
|
|
|
|
12-11-2008, 07:13 AM
|
#3
|
|
Member
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731
Rep: 
|
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.
|
12-11-2008, 09:38 AM
|
#4
|
|
Member
Registered: Dec 2008
Posts: 61
Original Poster
Rep:
|
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
|
|
|
|
12-12-2008, 08:13 AM
|
#5
|
|
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
|
Please, put your code in "Code:" blocks, i.e. put it inside [CODE][/CODE] tags.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:37 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|