Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kill Specific PPID 1

Status
Not open for further replies.

heprox

IS-IT--Management
Dec 16, 2002
178
US
I have several Oracle instances running on a AIX 4.3 box. I use terminal emulation to connect several different types of terminals to this server including RF terminals. Whenever an RF terminal disconnects incorrectly it leaves behind a spinning process with a PPID of 1:

oracle 130696 1 8 07:30:59 - 20:34 oraclegenret (LOCAL=NO)

I can sort for these processes easy enough with:

ps -ef | grep LOCAL=NO

what would be the best way to build a Korn script to identify and kill these processes using something like:

kill -9 130696 #130696 being the PID of the spinnig process

Anyone?
 
if on Solaris:
man pkill

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Try

#!/bin/ksh

a=`ps -ef|grep LOCAL=NO|awk '{print $2}`

for i in $a
do
kill -9 $a
done

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
That should be

a=`ps -ef|grep LOCAL=NO|grep -v grep|awk '{print $2}'

the grep -v grep tells the grep not to find itself....

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Just as a sideline I would run this from crontab and if you want to test the code start a couple of sleep processes

sleep 1000 &
sleep 1000 &

and replace the LOCAL=NO with sleep

Regards

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
I would be v-e-r-y careful just grepping for LOCAL=NO. How are you going to be able to distinguish between one of the spinning RF connections and a DBA who is using an Oracle tool from his/her desktop?
 
True

Grep for &quot;oraclegenret (LOCAL=NO)&quot;

or find the cause of the sessions hanging.....

--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Thanks for all of your help. I had orginally planned to build this as a Korn script then place it in /usr/bin and have crontab run it hourly. Luckily, the spinning process changes to &quot;LOCAL=NO&quot; when the terminal disconnects; when active it actually is:

oraclegenret (DESCRIPTION=(LOCAL=YES)

and the owner is actually the user connected. When the session is incorrectly terminated the owner becomes &quot;oracle&quot; and the session defaults to &quot;LOCAL=NO&quot;
 
Again, be very careful about killing any LOCAL=NO process, because you could be killing a DBA doing work on the database from a PC. The owner of a connection through DBA Studio is &quot;oracle,&quot; for example.
 
Syntax error:

/usr/bin/spin_kill[3]: 0403-057 Syntax error at line 3 : ``' is not matched.

I've apparently gone stupid today, because I cannot get this to work correctly.

 
Can you print the code you are using?
 
#!/bin/ksh

a=`ps -ef|grep LOCAL=NO|grep -v grep|awk '{print $2}'

for i in $a
do
kill -9 $a
done
 
IMHO, you have several things to see in your script:
Code:
#!/bin/ksh
a=`ps -ef|grep &quot;LOCAL=NO&quot;|grep -v grep|awk '{print $2}'`                                                    
for i in $a
do
kill -9 $i 
done

Hope This Help
PH.
 
Just for fun, a one line version:
Code:
kill -9 $(ps -ef|awk '/grep/{next}/LOCAL=NO/{print $2}') 2>/dev/null

Hope This Help
PH.
 
That was it, I told you I'm apparently stupid today...
 
Interesting to see the &quot;grep -v grep&quot; part used in this example to not list the grep process itself.

What I tend to use is &quot;grep [L]OCAL=NO&quot;, this works for me in AIX ksh. Does it work the same on Solaris?

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
MS Certified Windblows Rebooter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top