Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Kimberly .

Asked: May 02, 2000 - 1:21 pm UTC

Last updated: June 04, 2004 - 4:55 pm UTC

Version:

Viewed 1000+ times

You Asked

I need to find out Oracle users who have
been inactive for 30 minutes or more, so I can
kill them. Any ideas how to do this?

thanks.



and Tom said...



Have you looked at resource profiles? resource profiles are setup to do exactly this. You can set a maximum connect idle time. The sessions will be marked for kill when they exceed this limit.

In 7.3 and up, you can get this out of v$session:

ops$tkyte@8i> select sid,
2 username,
3 status,
4 to_char(logon_time,'dd-mm-yy hh:mi:ss') "LOGON",
5 floor(last_call_et/3600)||':'||
6 to_char(floor(mod(last_call_et,3600)/60),'fm00')||':'||
7 to_char(mod(mod(last_call_et,3600),60),'fm00') "IDLE",
8 program
9 from v$session
10 where type='USER'
11 order by last_call_et
12 /

SID USERNAME STATUS LOGON IDLE PROGRAM
---------- --------------- ---------- ----------------- ---------- -------------------------
119 OPS$TKYTE ACTIVE 28-02-00 02:12:15 0:00:00 sqlplus@aria (TNS V1-V3)
89 WEB$LALBRIGH ACTIVE 28-02-00 02:29:46 0:00:02 wrb21@aria (TNS V1-V3)
54 WEB$JGEMMELL ACTIVE 28-02-00 02:29:44 0:00:03 wrb21@aria (TNS V1-V3)
57 SCOTT INACTIVE 28-02-00 02:19:25 0:09:10 sqlplus@aria (TNS V1-V3)
110 OPS$CLBECK INACTIVE 28-02-00 02:03:22 0:23:10 sqlplus@aria (TNS V1-V3)
101 HOTEL INACTIVE 28-02-00 01:45:44 0:24:01 sqlplus@aria (TNS V1-V3)
88 REVIEW INACTIVE 28-02-00 08:38:16 5:42:45 sqlplus@aria (TNS V1-V3)




--
Thanks,

Thomas Kyte asktom_us@oracle.com
Oracle Service Industries

Oracle tips and papers </code> https://asktom.oracle.com/magazine-archive.htm <code>





Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

idel time

Mo, August 16, 2002 - 11:30 am UTC

Tom:

How do you do this in 8i?

Thanks

The same way

A reader, June 04, 2004 - 4:55 pm UTC

The same way