Kill Oracle process without specifying process ID
Make sure you always test the steps outlined in this 'Kill Oracle process ' tutorial on a test server before implementing it on a production system !
(listener,instance, agent, oms) then you will enjoy using this little script as much as I do now that I've found it.
Be very careful with it, if you get the 'requirement' wrong, you could end up killing the wrong processes.
For example, if you want to kill all processes associated with one particular SID, but have multiple SIDs running on your server,
don't grep for 'oracle' as the list that is returned is for ALL oracle processes on the server.
In this example, I need to kill all processed associated with the Oracle management agent (emagent) on a server.
I do not need to worry about being careful as I only have one agent home on the server and can not accidentally kill irrelevant ones.
$ps -ef | grep emagent
oracle 395 14244 0 15:10 pts/1 00:00:00
grep emagent
oracle 3905 1 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/perl/bin/perl
/home/oracle/product/agent10g/bin/emwd.pl
agent /home/oracle/product/agent10g/sysman/log/emagent.nohup
oracle 3922 3905 0 13:45 pts/1 00:00:08
/home/oracle/product/agent10g/bin/emagent
oracle 3928 3922 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 3929 3928 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 3930 3928 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 3931 3928 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 3932 3928 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4019 3928 0 13:45 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4233 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4235 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4236 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4237 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4238 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4239 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4240 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 4241 3928 0 13:46 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
oracle 14736 3928 0 14:41 pts/1 00:00:00
/home/oracle/product/agent10g/bin/emagent
$ps -ef | grep emagent| awk '{print $2}' | xargs kill -9
$
$ps -ef | grep emagent
oracle 27931 14244 0 15:26 pts/1 00:00:00 grep emagent