How to kill session in Oracle on Unix and Windows using command line?

by / 2009-2010 / Published in Oracle DBA Tips

kill session

In various critical situations Oracle DBA has to decide to kill existing session or kill the background process of Oracle database. At this moment remote Oracle DBA should need to terminate session/process called as termination of session of any instance.

If you want kill or terminate process using only operating system command. This is basic requirement when you are working as remote dba and providing remote dba services to different clients. Command line execution is most important thing to maintain client security and performance of server. How can you kill process in Unix?

In Unix and Linux using kill command:

Kill Oracle process using command line only:

We can check running processes in Unix and Linux using "ps" command. We are able to get process id from said command.

$ps -ef|grep ora_|grep -v grep

Now use "kill" command with "-9" syntax to kill process id as given below example.kill command with -9 for ensure not blocking command and surity if execution of "kill" command.

$kill -9 1451

In Windows using ORAKILL command:

Oracle DBA Interview Questions

For using ORAKILL utility we should need process id from sqlplus. ORAKILL utility is shipped with Oracle software itself. When we install Oracle software same time ORAKILL also is being installed in ORACLE_HOME\bin folder. It can kill process same as "kill -9" command in Unix/Linux. But one drowback of this utility that is we need process id using sqlplus and from v$process,v$session data dictionary views as follows.

SQL> select a.username, b.spid from v$session a, v$process b where a.paddr = b.addr and a.username ='SCOTT';
-------- ----
SCOTT 1456

Now we can kill server process of 1456 of scott user using ORAKILL utility from command line of Windows as follows.

C:\> orakill instance_name spid
C:\> orakill orcl 1456

We will get following message in our command prompt of windows.

"Kill of thread id 1456 in instance ORCL successfully signalled[sic]."

In Windows using TASKKILL command:

We can use TASKKILL command for terminating instance. Using tasklist command we can get thread id of Oracle.exe and using TASKKILL command we can terminate or kill instance in command line as follows.

Image Name PID Session Name Session# Mem Usage
=============== ======== ======== ============
System Idle Process 0 Console 0 16 K
oracle.exe 1456 Console 0 282,100 K
smss.exe 636 Console 0 420 K

C:\>taskkill /pid 1456 /T

In Windows using NET stop and NET start command:

Alternate we can stop and start service of Oracle instance using command line option of service as follows.It can be done using "NET start" and "NET stop" command using instance service name.

C:\>NET STOP "OracleServiceORCL"
C:\>NET START "OracleServiceORCL"

Means there are different ways to kill session or process in Unix and Windows. Both operating system has own command options.

Dbametrix is expert remote dba service provider team. Dbametrix has solid understanding to make SLA as per specification and requirement of client and end users. Dbametrix believes to provide remote dba services of database administration using SLA. Due to this reason client of Dbametrix can able to put trust on company because Dbametrix delivers cost effective remote dba plan using Service Level Agreement SLA and response time matrix.

Dbametrix is world wide leader in remote dba support. Expert remote DBA team of Dbametrix is offering high quality professional Oracle DBA support with strong response time to fulfill your SLA. Contact our sales department for more information.

Check another articles on same topic of different execution type.
How to kill session in Oracle RAC database::
How to kill session in Oracle using SQL*Plus::
How to kill session in Oracle 11g new feature::