使用下面的脚本找出v$session中status值为killed的会话信息
- set pages 2000
- set lines 170
- select distinct spid, program
- from (select a.spid, a.program
- from v$process a
- where a.BACKGROUND is null
- MINUS
- select a.spid, a.PROGRAM
- from v$process a, v$session b
- where a.addr = b.paddr) c
- where c.program not like '%(%'
- and c.spid is not null
- /
- select count(*) from v$session where status='KILLED'
- /
- select 'kill -9 ' || spid
- from (select distinct c.spid
- from (select a.spid, a.program
- from v$process a
- where BACKGROUND is null
- MINUS
- select a.spid, a.PROGRAM
- from v$process a, v$session b
- where a.addr = b.paddr) c
- where c.program not like '%(%'
- and c.spid is not null)
下面是正式环境的输出结果
- SQL> @sess_kill_killed.sql
- SPID PROGRAM
- ------------ ------------------------------------------------
- 1024584 oracle@crm2db3
- 1057512 oracle@crm2db3
- 1082350 oracle@crm2db3
- 1098706 oracle@crm2db3
- 1106278 oracle@crm2db3
- 1221336 oracle@crm2db3
- 1274242 oracle@crm2db3
- 1315240 oracle@crm2db3
- 1364358 oracle@crm2db3
- 1433856 oracle@crm2db3
- 1450998 oracle@crm2db3
- 1504420 oracle@crm2db3
- 1540534 oracle@crm2db3
- 1585670 oracle@crm2db3
- 1593726 oracle@crm2db3
- 1610154 oracle@crm2db3
- 1626600 oracle@crm2db3
- 1676372 oracle@crm2db3
- 1712758 oracle@crm2db3
- 1725588 oracle@crm2db3
- 1827464 oracle@crm2db3
- 1835806 oracle@crm2db3
- 1880574 oracle@crm2db3
- 1889352 oracle@crm2db3
- 1909006 oracle@crm2db3
- 1917578 oracle@crm2db3
- 1925730 oracle@crm2db3
- 2060840 oracle@crm2db3
- 2068996 oracle@crm2db3
- 2085508 oracle@crm2db3
- 2097626 oracle@crm2db3
- 2150814 oracle@crm2db3
- 2163050 oracle@crm2db3
- 2195850 oracle@crm2db3
- 2216908 oracle@crm2db3
- 2224598 oracle@crm2db3
- 2290392 oracle@crm2db3
- 233994 oracle@crm2db3
- 2429608 oracle@crm2db3
- 2438348 oracle@crm2db3
- 2442206 oracle@crm2db3
- 2450452 oracle@crm2db3
- 2458048 oracle@crm2db3
- 2511242 oracle@crm2db3
- 2523768 oracle@crm2db3
- 2540240 oracle@crm2db3
- 2552884 oracle@crm2db3
- 2564534 oracle@crm2db3
- 2621954 oracle@crm2db3
- 2675160 oracle@crm2db3
- 2696124 oracle@crm2db3
- 2711670 oracle@crm2db3
- 2715652 oracle@crm2db3
- 2745566 oracle@crm2db3
- 2748894 oracle@crm2db3
- 2773536 oracle@crm2db3
- 2785958 oracle@crm2db3
- 2801784 oracle@crm2db3
- 2822762 oracle@crm2db3
- 2850998 oracle@crm2db3
- 2908432 oracle@crm2db3
- 2925518 oracle@crm2db3
- 2929168 oracle@crm2db3
- 2949532 oracle@crm2db3
- 2969872 oracle@crm2db3
- 2990786 oracle@crm2db3
- 3006988 oracle@crm2db3
- 303672 oracle@crm2db3
- 3056254 oracle@crm2db3
- 3077108 oracle@crm2db3
- 3105204 oracle@crm2db3
- 3142068 oracle@crm2db3
- 3158742 oracle@crm2db3
- 3195904 oracle@crm2db3
- 320000 oracle@crm2db3
- 3244822 oracle@crm2db3
- 3326286 oracle@crm2db3
- 3379838 oracle@crm2db3
- 3380452 oracle@crm2db3
- 3404614 oracle@crm2db3
- 3477872 oracle@crm2db3
- 3555760 oracle@crm2db3
- 356632 oracle@crm2db3
- 3589304 oracle@crm2db3
- 3601098 oracle@crm2db3
- 3613750 oracle@crm2db3
- 3617122 oracle@crm2db3
- 3634356 oracle@crm2db3
- 3642372 oracle@crm2db3
- 3703674 oracle@crm2db3
- 3727974 oracle@crm2db3
- 3748112 oracle@crm2db3
- 385416 oracle@crm2db3
- 3875864 oracle@crm2db3
- 3961244 oracle@crm2db3
- 3969844 oracle@crm2db3
- 3973882 oracle@crm2db3
- 3977890 oracle@crm2db3
- 3989828 oracle@crm2db3
- 4010452 oracle@crm2db3
- 4022582 oracle@crm2db3
- 4027320 oracle@crm2db3
- 4030898 oracle@crm2db3
- 4047532 oracle@crm2db3
- 4072346 oracle@crm2db3
- 4088674 oracle@crm2db3
- 4108650 oracle@crm2db3
- 4158164 oracle@crm2db3
- 4174934 oracle@crm2db3
- 4207570 oracle@crm2db3
- 4223728 oracle@crm2db3
- 4224250 oracle@crm2db3
- 4289226 oracle@crm2db3
- 4301398 oracle@crm2db3
- 4309270 oracle@crm2db3
- 4346662 oracle@crm2db3
- 4363424 oracle@crm2db3
- 4387444 oracle@crm2db3
- 4403500 oracle@crm2db3
- 4412556 oracle@crm2db3
- 4489548 oracle@crm2db3
- 4514070 oracle@crm2db3
- 4551840 oracle@crm2db3
- 4608738 oracle@crm2db3
- 4629754 oracle@crm2db3
- 4641310 oracle@crm2db3
- 4645360 oracle@crm2db3
- 4657596 oracle@crm2db3
- 4699202 oracle@crm2db3
- 4723424 oracle@crm2db3
- 4740140 oracle@crm2db3
- 4756720 oracle@crm2db3
- 4825764 oracle@crm2db3
- 484220 oracle@crm2db3
- 4904074 oracle@crm2db3
- 4940656 oracle@crm2db3
- 4989356 oracle@crm2db3
- 5005902 oracle@crm2db3
- 5009924 oracle@crm2db3
- 5092498 oracle@crm2db3
- 5096058 oracle@crm2db3
- 5100424 oracle@crm2db3
- 5132592 oracle@crm2db3
- 5141660 oracle@crm2db3
- 5161346 oracle@crm2db3
- 5161714 oracle@crm2db3
- 5165444 oracle@crm2db3
- 517180 oracle@crm2db3
- 5218856 oracle@crm2db3
- 5255808 oracle@crm2db3
- 5297062 oracle@crm2db3
- 5333930 oracle@crm2db3
- 5341786 oracle@crm2db3
- 5366594 oracle@crm2db3
- 5399586 oracle@crm2db3
- 5436528 oracle@crm2db3
- 5440568 oracle@crm2db3
- 5460476 oracle@crm2db3
- 5481248 oracle@crm2db3
- 5497724 oracle@crm2db3
- 5522054 oracle@crm2db3
- 5522200 oracle@crm2db3
- 5530220 oracle@crm2db3
- 5530592 oracle@crm2db3
- 5538368 oracle@crm2db3
- 5567292 oracle@crm2db3
- 5584022 oracle@crm2db3
- 5596098 oracle@crm2db3
- 5608530 oracle@crm2db3
- 5616460 oracle@crm2db3
- 5636858 oracle@crm2db3
- 5670062 oracle@crm2db3
- 5685842 oracle@crm2db3
- 5694232 oracle@crm2db3
- 5710404 oracle@crm2db3
- 5809030 oracle@crm2db3
- 5825262 oracle@crm2db3
- 5825692 oracle@crm2db3
- 5841574 oracle@crm2db3
- 590146 oracle@crm2db3
- 5984968 oracle@crm2db3
- 5989406 oracle@crm2db3
- 6017776 oracle@crm2db3
- 6030186 oracle@crm2db3
- 6050874 oracle@crm2db3
- 6071362 oracle@crm2db3
- 6083134 oracle@crm2db3
- 6087916 oracle@crm2db3
- 611444 oracle@crm2db3
- 6120672 oracle@crm2db3
- 6136864 oracle@crm2db3
- 6218284 oracle@crm2db3
- 6243566 oracle@crm2db3
- 6247128 oracle@crm2db3
- 6263416 oracle@crm2db3
- 6275912 oracle@crm2db3
- 6350024 oracle@crm2db3
- 6366076 oracle@crm2db3
- 6415478 oracle@crm2db3
- 6423058 oracle@crm2db3
- 6443536 oracle@crm2db3
- 6476320 oracle@crm2db3
- 6615644 oracle@crm2db3
- 6763024 oracle@crm2db3
- 6832828 oracle@crm2db3
- 701550 oracle@crm2db3
- 713406 oracle@crm2db3
- 7213792 oracle@crm2db3
- 7230200 oracle@crm2db3
- 7271112 oracle@crm2db3
- 7410388 oracle@crm2db3
- 746200 oracle@crm2db3
- 7578280 oracle@crm2db3
- 7651928 oracle@crm2db3
- 7684666 oracle@crm2db3
- 7721518 oracle@crm2db3
- 7770776 oracle@crm2db3
- 7778960 oracle@crm2db3
- 7783070 oracle@crm2db3
- 7823944 oracle@crm2db3
- 7852720 oracle@crm2db3
- 791192 oracle@crm2db3
- 7938772 oracle@crm2db3
- 7950870 oracle@crm2db3
- 8061602 oracle@crm2db3
- 8069848 oracle@crm2db3
- 807224 oracle@crm2db3
- 811516 oracle@crm2db3
- 8151706 oracle@crm2db3
- 8245922 oracle@crm2db3
- 8323762 oracle@crm2db3
- 8344218 oracle@crm2db3
- 8446586 oracle@crm2db3
- 8508048 oracle@crm2db3
- 852740 oracle@crm2db3
- 8675996 oracle@crm2db3
- 873540 oracle@crm2db3
- 8827568 oracle@crm2db3
- 8831702 oracle@crm2db3
- 885642 oracle@crm2db3
- 8942276 oracle@crm2db3
- 9056824 oracle@crm2db3
- 913708 oracle@crm2db3
- 9183962 oracle@crm2db3
- 9249526 oracle@crm2db3
- 9274080 oracle@crm2db3
- 9277968 oracle@crm2db3
- 9413136 oracle@crm2db3
- 942766 oracle@crm2db3
- 9429716 oracle@crm2db3
- 9474750 oracle@crm2db3
- 9663020 oracle@crm2db3
- 252 rows selected.
- COUNT(*)
- ----------
- 252
- 'KILL-9'||SPID
- --------------------
- kill -9 1593726
- kill -9 2458048
- kill -9 2511242
- kill -9 2850998
- kill -9 303672
- kill -9 3105204
- kill -9 3379838
- kill -9 3601098
- kill -9 3748112
- kill -9 4030898
- kill -9 4047532
- kill -9 4088674
- kill -9 4158164
- kill -9 4174934
- kill -9 4223728
- kill -9 4224250
- kill -9 4489548
- kill -9 4551840
- kill -9 5100424
- kill -9 5460476
- kill -9 5809030
- kill -9 5841574
- kill -9 6275912
- kill -9 6763024
- kill -9 713406
- kill -9 7213792
- kill -9 807224
- kill -9 8508048
- kill -9 8675996
- kill -9 9183962
- kill -9 9274080
- kill -9 9429716
- kill -9 1725588
- kill -9 1880574
- kill -9 1909006
- kill -9 2060840
- kill -9 2216908
- kill -9 2224598
- kill -9 233994
- kill -9 2442206
- kill -9 2450452
- kill -9 2715652
- kill -9 2785958
- kill -9 2929168
- kill -9 2990786
- kill -9 3555760
- kill -9 3634356
- kill -9 4514070
- kill -9 4756720
- kill -9 5165444
- kill -9 5218856
- kill -9 5636858
- kill -9 5825262
- kill -9 5989406
- kill -9 6071362
- kill -9 6423058
- kill -9 6443536
- kill -9 885642
- kill -9 9056824
- kill -9 9413136
- kill -9 942766
- kill -9 1057512
- kill -9 1082350
- kill -9 1364358
- kill -9 1585670
- kill -9 1676372
- kill -9 2150814
- kill -9 2523768
- kill -9 2801784
- kill -9 2908432
- kill -9 2925518
- kill -9 320000
- kill -9 3617122
- kill -9 3642372
- kill -9 4346662
- kill -9 4699202
- kill -9 4989356
- kill -9 5161346
- kill -9 5436528
- kill -9 5481248
- kill -9 5530592
- kill -9 7778960
- kill -9 7823944
- kill -9 7852720
- kill -9 8151706
- kill -9 8323762
- kill -9 9249526
- kill -9 9277968
- kill -9 1315240
- kill -9 1540534
- kill -9 1835806
- kill -9 2540240
- kill -9 2552884
- kill -9 2564534
- kill -9 2748894
- kill -9 356632
- kill -9 3613750
- kill -9 3973882
- kill -9 4027320
- kill -9 4207570
- kill -9 4904074
- kill -9 5092498
- kill -9 5341786
- kill -9 5497724
- kill -9 5608530
- kill -9 611444
- kill -9 6120672
- kill -9 6243566
- kill -9 7684666
- kill -9 7721518
- kill -9 7783070
- kill -9 7938772
- kill -9 9474750
- kill -9 1024584
- kill -9 1098706
- kill -9 1106278
- kill -9 1450998
- kill -9 1712758
- kill -9 2097626
- kill -9 2621954
- kill -9 2675160
- kill -9 2969872
- kill -9 3056254
- kill -9 3326286
- kill -9 3380452
- kill -9 3703674
- kill -9 3989828
- kill -9 4010452
- kill -9 4022582
- kill -9 4072346
- kill -9 4403500
- kill -9 4641310
- kill -9 4657596
- kill -9 484220
- kill -9 5009924
- kill -9 5132592
- kill -9 5255808
- kill -9 5297062
- kill -9 5333930
- kill -9 5567292
- kill -9 5694232
- kill -9 6083134
- kill -9 6087916
- kill -9 6136864
- kill -9 6415478
- kill -9 6476320
- kill -9 746200
- kill -9 7950870
- kill -9 8069848
- kill -9 873540
- kill -9 9663020
- kill -9 1221336
- kill -9 1433856
- kill -9 1504420
- kill -9 1610154
- kill -9 1626600
- kill -9 2195850
- kill -9 2290392
- kill -9 2711670
- kill -9 2773536
- kill -9 3077108
- kill -9 3142068
- kill -9 3158742
- kill -9 3244822
- kill -9 3477872
- kill -9 385416
- kill -9 3961244
- kill -9 4301398
- kill -9 4309270
- kill -9 4363424
- kill -9 4608738
- kill -9 4723424
- kill -9 4740140
- kill -9 5366594
- kill -9 5596098
- kill -9 5616460
- kill -9 6350024
- kill -9 6832828
- kill -9 7410388
- kill -9 791192
- kill -9 8061602
- kill -9 8446586
- kill -9 852740
- kill -9 1827464
- kill -9 2429608
- kill -9 2438348
- kill -9 2696124
- kill -9 2745566
- kill -9 2949532
- kill -9 3006988
- kill -9 3195904
- kill -9 3875864
- kill -9 3977890
- kill -9 4412556
- kill -9 4645360
- kill -9 5005902
- kill -9 5096058
- kill -9 5161714
- kill -9 5522054
- kill -9 5530220
- kill -9 5538368
- kill -9 5584022
- kill -9 5670062
- kill -9 5685842
- kill -9 5710404
- kill -9 6017776
- kill -9 6050874
- kill -9 6247128
- kill -9 6263416
- kill -9 6366076
- kill -9 701550
- kill -9 7770776
- kill -9 8245922
- kill -9 8344218
- kill -9 913708
- kill -9 1274242
- kill -9 1889352
- kill -9 1917578
- kill -9 1925730
- kill -9 2068996
- kill -9 2085508
- kill -9 2163050
- kill -9 2822762
- kill -9 3404614
- kill -9 3589304
- kill -9 3727974
- kill -9 3969844
- kill -9 4108650
- kill -9 4289226
- kill -9 4387444
- kill -9 4629754
- kill -9 4825764
- kill -9 4940656
- kill -9 5141660
- kill -9 517180
- kill -9 5399586
- kill -9 5440568
- kill -9 5522200
- kill -9 5825692
- kill -9 590146
- kill -9 5984968
- kill -9 6030186
- kill -9 6218284
- kill -9 6615644
- kill -9 7230200
- kill -9 7271112
- kill -9 7578280
- kill -9 7651928
- kill -9 811516
- kill -9 8827568
- kill -9 8831702
- kill -9 8942276
- 252 rows selected.
把上面的内容复制到操作系统执行就可以了。
我们也可以在kill前面多提示一个host 那样在sqlplus中也可以执行这样的语句。