Wiki source code of Killing WOA Processes

Last modified by Yana Oksner on 2026/01/08 11:44

Hide last authors
David Avendasora 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.
smmccraw 1.1 2
Pascal Robert 3.1 3 Try to use lsof. You need to run it with admin privileges so the command is
smmccraw 1.1 4
Yana Oksner 10.1 5 {{code}}
smmccraw 1.1 6
Pascal Robert 3.1 7 sudo lsof -i tcp:xxxx
smmccraw 1.1 8
Yana Oksner 10.1 9 {{/code}}
smmccraw 1.1 10
11 Alternatively you can have a script:
12
Pascal Robert 3.1 13 {{code}}
smmccraw 1.1 14
Pascal Robert 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;}'`
smmccraw 1.1 20
Pascal Robert 3.1 21 {{/code}}
smmccraw 1.1 22
23 You will also have to do a sudo for the script to run.
24
David Avendasora 8.1 25 For those stuck with the CLOSE_WAIT problems try this:
smmccraw 1.1 26
Yana Oksner 10.1 27 {{code}}
smmccraw 1.1 28
Pascal Robert 3.1 29 sudo lsof -i tcp:xxxx
smmccraw 1.1 30
Yana Oksner 10.1 31 {{/code}}
smmccraw 1.1 32
33 Alternatively you can have a script:
34
Pascal Robert 3.1 35 {{code}}
smmccraw 1.1 36
Pascal Robert 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;}'`
smmccraw 1.1 42
Pascal Robert 3.1 43 {{/code}}
smmccraw 1.1 44
45 run it by doing:
46
Yana Oksner 10.1 47 {{code}}
smmccraw 1.1 48
Pascal Robert 3.1 49 sudo ./portslay xxxx-yyyy
smmccraw 1.1 50
Yana Oksner 10.1 51 {{/code}}
smmccraw 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
Yana Oksner 10.1 59 {{code}}
smmccraw 1.1 60
Pascal Robert 3.1 61 ps aux | grep java | grep <appName> | grep -v grep | awk '{ print"kill -9 "$2 }' | sh
smmccraw 1.1 62
Yana Oksner 10.1 63 {{/code}}
Pascal Robert 3.1 64
65 \\
66
67 === Mike Schrag ===
68
smmccraw 1.1 69 I just use
70
Yana Oksner 10.1 71 {{code}}
smmccraw 1.1 72
Pascal Robert 3.1 73 ps auxww
smmccraw 1.1 74
75
Yana Oksner 10.1 76 {{/code}}
Pascal Robert 3.1 77
David Avendasora 8.1 78 which will show the full commandline. You can see the app name from this view.
smmccraw 1.1 79
80 === Fabian Peters ===
81
82 On FreeBSD one needs to set
83
Yana Oksner 10.1 84 {{code}}
smmccraw 1.1 85
Pascal Robert 3.1 86 kern.ps_arg_cache_limit=1024
smmccraw 1.1 87
Yana Oksner 10.1 88 {{/code}}
smmccraw 1.1 89
David Avendasora 8.1 90 in /etc/sysctl to reveal the full command line with ps -auxww. To set it immediately:
smmccraw 1.1 91
Yana Oksner 10.1 92 {{code}}
smmccraw 1.1 93
Pascal Robert 3.1 94 sysctl kern.ps_arg_cache_limit=1024
smmccraw 1.1 95
Yana Oksner 10.1 96 {{/code}}
smmccraw 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}}