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

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

Tips and technical articles of Oracle DBA
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 murder of session of any instance.

If you want kill or terminate process using only operating system command only.How can you kill process in Unix?

Kill Oracle process using command line only:

In Unix and Linux using kill command:
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:

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'; USERNAME SPID. -------- ---- 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:

But if sometime SQL*Plus doesn't working like database stuck or instance hang situation. We need to terminate Oracle instance. But we are unable to execute command using SQL*Plus "shutdown abort" or our shutdown abort command also stuck in Windows. Then how can we terminate instance? Yes, we can restart instance service from service menu. But if we want to use only command line then how to terminate instance or kill instance or background process.

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. C:\>tasklist 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.

Check another articles on same topic of different type.

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 services of database administration using SLA. Due to this reason Dbametrix offers SLA based cost effective remote dba plans. 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.

Comments

Popular posts from this blog

Reboot Exadata Machine

ORA-01565: error in identifying file '?/dbs/spfile@.ora'

STEPS TO troubleshoot long running concurrent request in R12.2.x