[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
portslay (Re: WO Deadlocking Summary, Resolution)
- Subject: portslay (Re: WO Deadlocking Summary, Resolution)
- From: marcel at metaobject.com (Marcel Weiher)
- Date: Wed Apr 17 05:50:57 2002
- In-reply-to: <B8E2E1EA.6810%tatsuyaml@mac.com>
On Wednesday, April 17, 2002, at 02:25 Uhr, Tatsuya Kawano wrote:
> portslay is great idea! thanks!
Glad you like it!
> However, when I use lsof on my Mac, I get a list of multiple processes
> like
> this:
>
> ---------------------------------------------
> tatsuyak% sudo lsof -i tcp:2002
>
> COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
> httpd 370 www 7u inet 0x05ae175c 0t0 TCP
> mydomain.com:56487->mydomain.com:globe (CLOSE_WAIT)
> java 535 root 3u inet 0x04c5b9ec 0t0 TCP *:globe (LISTEN)
> httpd 594 www 8u inet 0x05b2679c 0t0 TCP
> mydomain.com:56494->mydomain.com:globe (CLOSE_WAIT)
> --------------------------------------------
I saw this after I had posted my message.
> Is there any way to pick up "java" one instead of the last one?
Sure, just do a "grep java"
-------------- snip ----------
#!/bin/sh
#
# portslay: kill the task active on the specified TCP port
#
kill -9 `lsof -i tcp:$1 | grep java | awk '{ print $2;}'`
------------- snip -------------
> (I wish I know some shell scripting.)
Another thing you could is to look for the port that is LISTENing.
-------------- snip ----------
#!/bin/sh
#
# portslay: kill the task listening on the specified TCP port
#
kill -9 `lsof -i tcp:$1 | grep LISTEN | awk '{ print $2;}'`
------------- snip -------------
Marcel
--
Marcel Weiher Metaobject Software Technologies
marcel@xxxxxxxxxxxxxx www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.