?
Solved

SQL statment for Killing Sessions

Posted on 2004-03-28
6
Medium Priority
?
1,644 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 580 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

752 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