Home > Linux > Kill all Oracle sessions

Kill all Oracle sessions

set pagesize 0
spool kill_all.sql
select 'alter system kill session '''||sess.sid||', '||sess.serial#||''';' from v$session sess where username = 'OLASADM';
spool off
spool kill_all.log
spool off
ps -ef |grep AEGDWHPR | grep NO | grep -v grep | awk '{print $2}' | xargs kill -9 
SELECT c.sid, c.serial#, p.spid,
'ALTER SYSTEM KILL SESSION '''||c.sid||', '||c.serial#||
''' IMMEDIATE;' as ''KILL in ORACLE'',
'kill -9 '||p.spid as ''KILL in UNIX '',
c.STATUS, c.program, c.osuser,  c.machine, c.process, c.username
sys.v_$session c,
sys.v_$process p,
sys.user$ u
WHERE c.paddr = p.addr
AND u.user# = c.user#
AND c.username is not null
ORDER BY c.sid
Categories: Linux
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: