-
Kill The Inactive Session After 2 Hours
Can some body help in wrting the script for this to
KILL THE INACTIVE SESSION AFTER 2 HOURS ( if it is has inactive from last 2 hours or more.)
Thanks In Advance
-
Why don't you use profile (IDLE_TIME) ?
-
Thanks.
Can you give me an example.
-
Try this
SET RESOURCE_LIMIT=TRUE in your init.ora file
bounce ur DB
then
CREATE PROFILE IDLETEST LIMIT IDLE_TIME 120;
alter user TESTUSER profile IDLETEST;
HTH
Amar
Amar
"There is a difference between knowing the path and walking the path."
-
As adewri wrote, you need to create profile and assign it to the user.
CREATE PROFILE IDLETEST LIMIT IDLE_TIME n; where n is time specified in minutes.
IDLE_TIME: Specify the permitted periods of continuous inactive time during a session.
-
However setting profile with the IDLE_TIME will not actually kill the session after the specified time of inactivity! That session will stay there in inactive state even after the specified idle time. It will only be disconnected when next activity on that session is attempted. So if user doesn't get back and try to do something after two hours of inactivity, the session will still be hanging there on the database. It will still eating the resources, prossibly forewer if you don't kill it manually!
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
Use the v$session view to find the current sessions.
The LOGON_TIME field will give the logon time of a session.
If SYSDATE - LOGON_TIME is greater than 2 hours, then you found a session that has been active longer than two(2) hours.
Kill the session manually as jmodic stated
ALTER SYSTEM KILL SESSION 'sid,serial#'
P.S. Make sure you do NOT kill the oracle internal processes. If you do, you will crash the DB.
alapps
Fast, Cheap, Reliable... Pick Two(2)
-
you cannot use SYSDATE - LOGON_TIME to determine if a session can be killed or not
-
Of course, LOGON_TIME doesn't tell you anything about how long the sesson has been inactive. For that you have to check column LAST_CALL_ET, which stores the elapsed time in seconds from the last call to the RDBMS by that session.
To find all the sessions that have been inactive for more than 2 hours, your query would look something like:
Code:
SELECT * FROM v$session
WHERE STATUS != 'ACTIVE'
AND last_call_et > 2*60*60;
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|