Kill inactive sessions with no programs run it

hi all,
my database is 10gR2 with developer 6i
the database have huge number of sessions with no programs running it like oracle form, some of those sessions stack in v$session table due to power failure.
restart server solve the problem, but it is not efficient.
is there any method to fined witch of database sessions is actually connect to the database and have application running it ?

This script will give you the complete detail of Session , PID and Program which is running in dagtabase level.
You can include the "STATUS" coloumn from v$session to get user status.
Script is like this:
set echo off;
set termout on;
set linesize 80;
set pagesize 60;
set newpage 0;
select
rpad(c.name||':',11)||rpad(' current logons='||
(to_number(b.sessions_current)),20)||'cumulative logons='||
rpad(substr(a.value,1,10),10)||'highwater mark='||
b.sessions_highwater Information
from
v$sysstat a,
v$license b,
v$database c
where
a.name = 'logons cumulative'
ttitle "dbname Database|UNIX/Oracle Sessions";
set heading off;
select 'Sessions on database '||substr(name,1,8) from v$database;
set heading on;
select
substr(a.spid,1,9) pid,
substr(b.sid,1,5) sid,
substr(b.serial#,1,5) ser#,
substr(b.machine,1,6) box,
substr(b.username,1,10) username,
-- b.server,
substr(b.osuser,1,8) os_user,
substr(b.program,1,30) program
from v$session b, v$process a
where
b.paddr = a.addr
and type='USER'
order by spid;
ttitle off;
spool off;
Save this script with your desire name and run in Database.
Mukesh

Similar Messages

  • PL/SQL procedure to kill inactive session

    Hi all ,
    Please i am trying to write a procedure to kill inactive sessions of the shema 'TESTSCHEMA' .This is my first procedure , am not use to pl/sql but i went through many turtorial but have some errors at compliation .when i try to compile the procedure the errors are as below :
    15:50:28 Start Find Objects [TESTSCHEMA@TESTDB_UNIX(2)] ...
    15:50:28 End Find Objects [TESTSCHEMA@ TESTDB_UNIX(2)]
    15:50:32 Start Compiling 1 object(s) ...
    15:50:32 Executing ALTER PROCEDURE fib_dead_cnx_cleanup COMPILE ...
    15:50:32 [13:2] PL/SQL: ORA-00933: SQL command not properly ended
    15:50:32 [9:3] PL/SQL: SQL Statement ignored
    15:50:32 [18:12] PLS-00103: Encountered the symbol "(" when expecting one of the following:
    15:50:32 constant exception <an identifier>
    15:50:32 <a double-quoted delimited-identifier> table LONG_ double ref
    15:50:32 char time timestamp interval date binary national character
    15:50:32 nchar
    15:50:32 The symbol "<an identifier>" was substituted for "(" to continue.
    15:50:32 [18:21] PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
    15:50:32 := ; not null default character
    15:50:32 The symbol "; was inserted before "LOOP" to continue.
    15:50:32 [27:8] PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    15:50:32 begin case declare exit for goto if loop mod null pragma
    15:50:32 raise return select update while with <an identifier>
    15:50:32 <a double-quoted delimited-identifier> <a bind variable> <<
    15:50:32 close current delete fetch lock insert open rollback
    15:50:32 savepoint set sql execute commit forall merge pipe
    15:50:32 Compilation complete - 5 error(s) found
    15:50:32 End Compiling 1 object(s)
    below is the procedure code :
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
    l_serial     CHAR(100);
    l_sid CHAR (100);
    l_sid_serial CHAR(100);
    l_count      NUMBER(10,0);
    CURSOR session_cur IS
              SELECT sid,serial#,sid||','||serial# as sid_serial
         FROM v$session
         WHERE username='EBBFCAT' and schemaname='TESTSCHEMA'
         and status='INACTIVE'
    BEGIN
         BEGIN
         l_count := 0;
                   OPEN session_cur;
                        WHILE ( 1 = 1) LOOP
                             BEGIN
                                  FETCH session_cur INTO l_sid ,l_serial,l_sid_serial ;
                                       EXIT WHEN session_cur%NOTFOUND ;
                                  BEGIN
                                       alter system kill session 'l_sid_serial' ;
                                  END;     
                             END;
                        END;
                   CLOSE session_cur;
         END;
    END FIB_DEAD_CNX_CLEANUP;
    Thanks

    Hi,
    Never write, let alone post, unformatted code.
    When posting any formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Among the benefits of formatting: you can indent to show the extent of blocks, such as BEGIN-END.
    Different types of blocks need modifiers after the end, such as "END *IF* " and " END *LOOP* ". If each opening statement (BEGIN, IF, LOOP) is directly above its corresponding END, then it's easy to check if you got the right modifier.
    Here's what you code looks like with some formatting, and a couple of corrections added. Look for -- comments.
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
         l_serial     CHAR(100);
         l_sid          CHAR (100);
         l_sid_serial     CHAR(100);
         l_count          NUMBER(10,0);
         CURSOR session_cur IS
                SELECT  sid
                ,       serial#
                ,       sid     || ','
                                      || serial#     as sid_serial
                FROM     v$session
                WHERE      username     = 'EBBFCAT'
                and     schemaname     = 'TESTSCHEMA'
                and     status          = 'INACTIVE';          -- need semicolon here
    BEGIN
         BEGIN                                   -- Why?
              l_count := 0;
              OPEN session_cur;
              WHILE ( 1 = 1)
              LOOP
                    BEGIN                         -- Why?
                         FETCH  session_cur
                         INTO   l_sid
                         ,          l_serial
                         ,          l_sid_serial ;
                               EXIT WHEN session_cur%NOTFOUND ;
                         BEGIN                    -- Why?
                             alter system kill session 'l_sid_serial' ;    -- Not a PL/SQL command
                               END;
                          END;
                END LOOP;                         -- LOOP ends with END LOOP
                CLOSE session_cur;
            END;
    END      FIB_DEAD_CNX_CLEANUP;Take baby steps.
    I've been wrtiing PL/SQL for 20 years, and I would never write that much code at once. If you're a beginner, all the more reason to start small. Write as little as possible, test, debug and test again (if necessary). When you have someting working, add 2 or 3 more lines and test again.
    It looks like you have three BEGIN statements that don't serve any purpose. You should get rid of them (and their corresponding END statements, of course).
    One error I did not fix: ALTER SYSTEM is not a PL/SQL statement. It's a SQL statement. You can run a SQL statement inside PL/SQL by using dynamic SQL, where you construct a string containing the SQL statement, and then use dbms_sql or EXECUTE IMMEDIATE to run it.
    Edited by: Frank Kulash on Aug 18, 2009 12:37 PM

  • AUTOMATICALLY KILL  INACTIVE SESSIONS

    Hi all. we are using oracle 8.1.6 on windows-2000 with 2gb ram. we facing
    ora-12500 listner failed to start a dedicated server.
    error and for this we made certain changes. we also added a parameter in sqlnet.ora at server side sqlnet.expire_time=10.. for automatically killing inactive sessions but it did not helped and many sessions remain in v$session. i wana know what should we do to kill inactive sessions. because i think when the sessions reach more than 300 then we face problem of listner failed. thanks for u'r valueable comments in advance as well.
    best wishes
    muhammad mohsin chattha

    Hi Nicolas, what you say is correct, but, unless the user try to do something (and receives an error),
    those sessions will show up as SNIPED in V$SESSION, and never go away.
    We can create a procedure to kill these sessions, something like this :  1  CREATE OR REPLACE PROCEDURE Kill_Sessions   IS
      2      Stmt           VARCHAR2(200);
      3      V_Sid          VARCHAR2(30);
      4      V_Serial       VARCHAR2(30);
      5      V_Username     VARCHAR2(30);
      6      CURSOR pri IS
      7      SELECT Sid, Serial#, Username
      8      FROM V$Session
      9      WHERE Username Is Not Null
    10      And Username not like 'SYS%'
    11      And Status = 'SNIPED';
    12  BEGIN
    13      FOR usr in pri LOOP
    14      V_Sid     := usr.Sid;
    15      V_Serial  := Usr.Serial#;
    16      Stmt      := 'ALTER SYSTEM KILL SESSION ''' || V_Sid || ',' || V_Serial || '''';
    17      Execute Immediate(Stmt);
    18      END LOOP;
    19* END;
    20  /  and execute it every minute (change 1440 to change the frequence) :SQL> Declare
      2     Out_Var Int;
      3  Begin
      4     Dbms_Job.Submit(Out_Var,
      5     'Kill_Sessions;',
      6     Sysdate,
      7     'Sysdate+1/1440' );
      8* End;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>

  • When I run activity monitor with no programs running my dock shows fluctuating usage...between 4% up to 20%.  Random figures that come and go with corresponding CPU usage.  A little help?

    My activity monitor show random and fluctuating CPU usage at the Dock site with absolutelyno programs running.  %'s fluctuate between 3 - 20 and they pretty much come and go.  What might be causing this?

    There's a lot of background processes running that aren't documented as Apps as such. And some of them are the Time Machine backups, Spotlight searches, all kinds of small little bits of maintenance caches, there's a lot going on. So it's not completely out of the question that this is 'normal' for a Mac. If it were 50% or more I would be concerned but if it spikes up to 20% for a second or two you are probably not in any trouble of any kind.

  • DBA Reports large number of inactive sessions with 11.1.1.1

    All,
    We have installed System 11.1.1.1 on some 32 bit windows test machines running Windows Server 2003. Everything seems to be working fine, but recently the DBA is reporting that there are a large number of inactive sessions throwing alarms that we are reaching our Max Allowed Process on the Oracle Database server. We are running Oracle 10.2.0.4 on AIX.
    We also have some System 9.3.1 Development servers that point at separate schemas in this environment and we don't see the same high number of inactive connections?
    Most of the inactive connections are coming from Shared Services and Workspace. Anyone else see this or have any ideas?
    Thanks for any responses.
    Keith
    Just a quick update. Originally I said this was only with 11.1.1.1 but we see the same high number of inactive sessions in 9.3. Anyone else see a large number of inactive sessions. They show up in Oracle as JDBC_Connect_Client. Does Shared Service, Planning Workspace etc utilize persistent connections or does it just abandon sessions when the windows service associated with an application is shutdown? Any information or thoughts are appreciated.
    Edited by: Keith A on Oct 6, 2009 9:06 AM

    Hi,
    Not the answer you are looking for but have you logged it with Oracle as you might not get many answers to this question on here.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Arch loads with many programs running (from past shutdown)

    Hey, i remember this one time i was working on a paper and I think I shut down with all my programs running (i think i was in a hurry). Since then, I've booted up many times and every time I do, all those programs run at startup. I'm unsure of where I can stop these programs from running (perhaps I can simply change their locations so they can't run) but does Arch have some kind of similar program from Windows called "msconfig" which allows you to control which programs run at startup?
    Thanks.

    "Autoloading" has nothing to do with *arch* as such, it's a feature of some desktop environments, like xfce, gnome or kde. You need to look there. tigrmesh said how to do it with xfce. I think gnome has something like "session manager" in its system menu - check that one. I'm sure KDE has something similar, you should go through the control center.

  • Kill Inactive Sessions

    There are a lot of inactive sessions in my server, and I want to make a procedure to kill.But I can not use command like 'alert system kill session ...' in the procedure.
    How can I do it.

    Hi,
    Use the dbms_sql package to do the job.
    procedure(v_sid varchar2, v_serial varchar2);
    c number;
    n number;
    ssql varchar2(1000);
    begin
    c:=dbms_sql.open_cursor;
    sqlstr:='alter system kill session '&#0124; &#0124;
    ''''&#0124; &#0124;v_sid&#0124; &#0124;', '&#0124; &#0124;v_serial&#0124; &#0124;''''&#0124; &#0124;';';
    dbms_sql.parse(c, ssql, dbms_sql.native);
    n:=dbms_sql.execute(c);
    dbms_sql.close_cursor(c);
    end;
    null

  • Inactive sessions with sql_address=00

    hi gurus,
    db: oracle 11g
    application: weblogic
    i could see lots of invalid sessions with sql_address=00 and blank sql_id appearing intermittently and causing connection issues.
    prev_sql_id of majority of the rows are the same and the sql_text is "select count(*) from dual" !!!
    what could be the reason for these invalid sessions? not able to understand the prev sql_text also
    please help,
    charles

    The sessions are not invalid. They are just doing nothing.
    Also this does not cause connection problems.
    Applications like weblogic have several 'features'
    - They frequently execute dummy sql to check database availabilty, like select count(*) from dual
    - They don't have persistent connections
    This is addressed by setting up shared server and enabling connection pooling.
    Sybrand Bakker
    Senior Oracle DBA

  • Passing values with each program run

    Hi ,
    I have a program which runs 6 days a week and updates a table.Now my requirement is to assign a value to a field for each day when the program runs every day in the week.
    <b>For first day - D
    second day - D-1
    sixth day - D-5.</b>
    when the program runs after D-5 it should again start from D.
    How can i achieve this please advise.
    Regards
    Pavan

    Hi kumar,
    1.
    03-Jun-06     D
    04-Jun-06     D-1
    05-Jun-06     D-2
    06-Jun-06     D-3
    07-Jun-06     D-4
    08-Jun-06     D-5
    09-Jun-06     
    10-Jun-06     D
    11-Jun-06     D-1
    12-Jun-06     D-2
    13-Jun-06     D-3
    2. this program will give output,
       based upon date input.
    3.  just copy paste
    report abc.
    data : monday type sy-datum.
    data : abc(3) type c.
    data : diff type i.
    DATA : DAYNR TYPE C.
    parameters : mydate type sy-datum default sy-datum.
    START-OF-SELECTION.
    CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
    EXPORTING
       DATE          = mydate
    IMPORTING
      WEEK          =
       MONDAY        = monday
      SUNDAY        =
    DIFF  = MYDATE - MONDAY.
    DAYNR = DIFF.
    ABC = 'D'.
    IF DIFF >= 1.
    CONCATENATE ABC '-' DAYNR INTO ABC.
    ENDIF.
    WRITE ABC.
    regards,
    amit m.

  • Too much RAM usage with no programs running

    Macbook Pro-late 2009 model
    Snow Leopard 10.6.8
    4 gig RAM 1067 MHz DDR3
    2.53 GHz Intel Core Duo 2
    Bootcamp
    VMWare 3.13, Windows 7
    Even w/o Windows running and VMWare completely shut down, something is still gobbling up resources.  See Image.  My green resource aren't even at half of the memory.  I used to run Win XP Pro SP2 (the only decent windows OS), and my green resources barely got beyond half even with a trading program, QB for Mac and safari running on the Mac side.  Now, even if I completely shut down the windows side, including VMWare, I still don't have the same resources.  What gives?  I suspect Windows 7 is getting bigger and bigger (just like the other Win OS' do every time you need to update).  Perhaps a migrated virus?  Both the Apple store and the Microsoft store had no good answers, other than the insipid suggestion of re-installing the OS.  Any big brains in here have any ideas?  I should note that the Microsoft store gave me Windows 7 pro for free since they screwed up the update on XP (despite me telling them NOT to load service pack 3).  I was skeptical of Win 7, and frankly my computer has not performed as well since.  I only use Windows because some of my trading programs only run on Windows, and Quickbooks for Mac still *****.  My QB 2004 runs better and is easier to use even now, and I am one of the first 1000 (possibly 100 people to buy QB nearly 25 years ago).  Oh, and safari is constantly crashing.  I would rather just use the Mac 100% of the time, but unfortunately, being in finance and accounting, that is not an option until Intuit and the like stop s*cking Microsoft's you know what, and make better programs for Mac.  Mac hardware is way superior and prettier, and the OS much smoother imo, so please help.  Thank you.
    Grumpy Middle-aged Mac User

    There is nothing necessarily wrong with your Mac's use of system resources. Inactive "blue" memory may just as well be considered "green" in that is is available to any process that requires it. It is merely given that status in the event a process that previously used that memory requires it again. In that event, it's available right away. Otherwise, whatever it's used for would have to be created again, wasting time and degrading your Mac's performance.
    For a completely correct perspective regarding the memory pie chart, think of "inactive" as essentially "free", and "free" as a resource you paid for that is going completely unused and wasted.
    You will then conclude you really aren't using that much RAM. You aren't even using half of it. What you are observing is most likely the consequence of websites becoming ever more resource-hungry. That so-called progress will never be reversed, and remember that websites are created by programmers with $5000 workstations with 64 GB RAM and practically unlimited bandwidth. Their job is to please their bosses who have $10000 workstations and are easily impressed by flashy animations and other nonsense that others consider wasteful and distracting.
    Oh, and safari is constantly crashing.
    That is the only thing that should concern you. Safari shouldn't do that, so when it does next time post the crash report. Don't post anything below "Binary Images" - it's not useful.

  • I think I downloaded a fake Firefox update from supportfirefox.perl.sh - ever since I have had I/E popups and now audio playing with no programs running. What do I do?

    I use the Firefox Google as my homepage. I searched for something and it went to the "you need to update your firefox" so I did...then I realized that it wasn't processing the update the way a normal update from Firefox would. Ever since then, I have had Internet Explorer PopUps and now I have audio running even though there is no program for it to be running on...like a webpage running in the background.

    Do a full scan with your Anti-Virus application.
    Then do scans with different Malware applications.
    Install, update, and run these programs in this order. '''''(Not all programs detect the same Malware.)''''' They are all free for personal use, but some have limited functionality in the "free mode" - but those are features you really don't need to find and remove the problem that you have.<br />
    ''Note: If your Malware infection is bad enough and you are mis-directed to URL's other than what is posted, you may have to use a different PC to download these programs and use a USB stick to transfer them to the afflicted PC.''
    Malwarebytes' Anti-Malware - [http://www.malwarebytes.org/mbam.php] <br />
    SuperAntispyware - [http://www.superantispyware.com/] <br />
    AdAware - [http://www.lavasoftusa.com/software/adaware/] <br />
    Spybot Search & Destroy - [http://www.safer-networking.org/en/index.html] <br />
    Windows Defender: Home Page - [http://www.microsoft.com/windows/products/winfamily/defender/default.mspx]
    If these don't find it or can't clear it, post in one of these forums for specialized malware removal help: <br />
    [http://www.spywarewarrior.com/index.php] <br />
    [http://forum.aumha.org/] <br />
    [http://www.spywareinfoforum.com/] <br />
    [http://bleepingcomputer.com]

  • ITunes 7 not functioning with other programs running

    I used to have Itunes playing while i would play games on my computer but with the new itunes update to 7.0 which i had to do because i just got a new 5th gen ipod with its own set of problems, i now find that when i start another program which is taking about 55,555 mem usage the songs start to skip, jump, and have a static noise sound.

    Rolling back to 6 won't fix every thing, I rolled back..iTunes seams to work but programs that use to work using quicktime still have the jittery, jerky sound affects.
    It was a Reason Ask DVD Video (uses QT.7 that ran fine up until iTunes 7 was installed) run the dvd and any narration gets screwed up when you roll over the application button rollovers, so it has basically stuffed up the system sound, then the video has a hard time trying to catchup.

  • Choppy Music playback with other programs running

    Have a question on Itunes 7 playback. I frequently play games (mainly WOW) with the sound on, but at a low level. I then run Itunes in the background at a high volume level so I can listen to music. My computer is high end and I never had any problems doing this before. Now that I have upgraded to 7 the music is very choppy if the game is sending any sound output to the sound card. As soon as i turn in game sound off, the music playback is fine. Any ideas besides reverting to 6?

    Rolling back to 6 won't fix every thing, I rolled back..iTunes seams to work but programs that use to work using quicktime still have the jittery, jerky sound affects.
    It was a Reason Ask DVD Video (uses QT.7 that ran fine up until iTunes 7 was installed) run the dvd and any narration gets screwed up when you roll over the application button rollovers, so it has basically stuffed up the system sound, then the video has a hard time trying to catchup.

  • Adding Forms to .PDF with layers - program runs slow

    Hello:
    I am using Acrobat Professional 9.2.0
    I am working on converting an AutoCAD drawing to a PDF file.
    I created the .PDF drawing through the File, Create PDF, From File.
    The file created correctly and properly created the different layers of the AutoCAD drawing.
    Here's where the issue is ...
    When I attempt to insert form fields through the "add or edit fields" option, it is taking a long time.  For example, I'll draw a text box, and the program will hang showing  the "hour glass" for 13 to 15 seconds before I can draw the next box.
    This doesn't happen on a .PDF with no layers, or if I flatten the layers, it doesn't happen, so I am convinced it has to do with the layers.
    I have duplicated this on a Windows XP and Windows 7 (32 bit versions)
    Anyone know why?  Anyone have a solution?
    Thanks!

    But there is test with the title of the object type I can't seem to get rid of.
    This should read - "But there is TEXT..."
    The title of the object type is the object type as called by Adobe LiveCycle.

  • Imac5 cpu is running at 100% with no programs running.  How do I figure out what is causing this?

    My fan is running constantly and the cpu is at 100% without opening any programs.  It just started doing this yesterday.  I erased the console logs and that didn't help.  I've been looking on line for other possibilities, but not finding much.  I hope someone has some ideas.

    Try checking User>Applications>Utilities>Activity Monitor and see what's using up all the CPU.  If nothing shows up, then your power supply unit is faulty, leading your machine to think it's overheating.  You can also check in Console to see if there's any mention of maximum temperatures being exceeded (just enter those words in the little window at the upper right of the Console window).

Maybe you are looking for