Solved

SQL statment for Killing Sessions

Posted on 2004-03-28
6
1,630 Views
Last Modified: 2010-05-18
Hi!

I need a sql statement which will kill all inactive sessions.
Is it possible to schedule running of this statement every day at 1:00 AM?

TNX
0
Comment
Question by:Premanidhi
6 Comments
 
LVL 8

Expert Comment

by:baonguyen1
ID: 10702077
You can try this:

SQL>alter system kill session 'sid,serial#'

where the sid and serial# are from v$session view

Please note that as soon as you run a query and get the results back
in sqlplus, you will see  "inactive" seesions andmost sessions are mostly inactive.

A good way is to set an IDLE time in the PROFILES .  That will kill sessions that have been IDLE for "x" minutes.  Just killing inactive sessions would *not* be a good idea.

Hope this helps

0
 

Author Comment

by:Premanidhi
ID: 10702501
baonguyen1 Could You please explain me how to set IDLE time in the PROFILES?
 
0
 
LVL 8

Accepted Solution

by:
baonguyen1 earned 145 total points
ID: 10702774
You can do:

1. create a profile:

SQL>CREATE PROFILE <profile_name> LIMIT
IDLE_TIME <time in minute>;

For example:

SQL>CREATE PROFILE resourec_limit LIMIT
IDLE_TIME 60;

IDLE_TIME is the number of minutes a session can be connected to the db without being actively used.

Now grant profile to a user:

SQL>ALTER USER <USER>  PROFILE <PROFILE_NAME>;

For example:

SQL>ALTER USER ABC  PROFILE resourec_limit;

Hope this helps
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Expert Comment

by:boriskalavsky
ID: 10707085
The process will be sniped on IDLE time and then cleaned up by PMON (some times it does not work).
0
 

Expert Comment

by:idai
ID: 10730397


but AFAIK you have to set init.ora parameter RESOURCE_LIMIT=True
0
 
LVL 2

Expert Comment

by:vanmeerendonk
ID: 10732493
You could also use the last_call_et from v$session
sysdate - last_call_et/86400 is the last datatime the session "did"something.
We kill everybody that has done nothing for a day
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question