Version 2.1 by smmccraw on 2007/07/08 09:45

Show last authors
1 This is one of the most vexing question. How to kill a run away WO application? The ps command does not give you any information as it list the process as java.
2
3 Try to use lsof. You need to run it with admin privileges so the command is
4
5 {{panel}}
6
7 sudo lsof -i tcp:xxxx
8
9 {{/panel}}
10
11 Alternatively you can have a script:
12
13 {{panel}}
14
15 #!/bin/sh
16 #
17 # portslay: kill the task listening on the specified TCP port
18 #
19 kill -9 `lsof -i tcp:$1 | grep LISTEN | awk '{ print $2;}'`
20
21 {{/panel}}
22
23 You will also have to do a sudo for the script to run.
24
25 For those stuck with the CLOSE//WAIT problems try this~://
26
27 {{panel}}
28
29 sudo lsof -i tcp:xxxx
30
31 {{/panel}}
32
33 Alternatively you can have a script:
34
35 {{panel}}
36
37 #!/bin/sh
38 #
39 # portslay: kill the task listening on the specified TCP port
40 #
41 kill -9 `lsof -i tcp:$1 | grep CLOSE_WAIT | awk '{ print $2;}'`
42
43 {{/panel}}
44
45 run it by doing:
46
47 {{panel}}
48
49 sudo ./portslay xxxx-yyyy
50
51 {{/panel}}
52
53 where xxxx is the first port and yyyy the last port
54
55 ----
56
57 how about (pref. inside a script):
58
59 ps aux | grep java | grep <appName> | grep --v grep | awk '{ print"kill --9 "$2 }' | sh
60
61 === Mike Schrag ===
62
63 I just use
64
65 {{panel}}
66
67 ps auxww
68
69 {{/panel}}
70
71 which will show the full commandline. You can see the app name from this view.
72
73 === Fabian Peters ===
74
75 On FreeBSD one needs to set
76
77 {{panel}}
78
79 kern.ps_arg_cache_limit=1024
80
81 {{/panel}}
82
83 in /etc/sysctl to reveal the full command line with ps --auxww. To set it immediately:--
84
85 {{panel}}
86
87 sysctl kern.ps_arg_cache_limit=1024
88
89 {{/panel}}
90
91 Alternatively, one can use Johan's script below.
92
93 === Johan Henselmans ===
94
95 I have written a small script that uses lsof to find the process by looking at some specific file that is opened, the returned processes can then be used to kill the process
96
97 {{code}}
98
99 #!/bin/sh
100
101 if [ $# = 0 ]; then
102 {panel}
103 echo ""
104 echo " usage: $0 javaname(s)"
105 echo " The current processes that containt javaname will be displayed"
106 echo " eg: $0 JavaMonitor.woa"
107 echo ""
108 exit 1
109 {panel}
110 fi
111
112 OS=`uname -s`
113 # echo $OS
114 case ${OS} in
115 'FreeBSD')
116 LSOF=/usr/local/sbin/lsof
117 ;;
118 'Linux')
119 LSOF=/usr/sbin/lsof
120 ;;
121 'Darwin')
122 LSOF=/usr/sbin/lsof
123 ;;
124 *)
125 echo "no lsof command available on this OS!";
126 exit 1
127 ;;
128 esac
129
130 for i in $*
131 do
132 ${LSOF} -c java | grep -i $i | awk '{print $2}' | sort -u;
133 done
134
135 {{/code}}
136
137 Category:WebObjects