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