[CentOS] netstat - kill by pid ?

Silviu Hutanu silviuhutanu at gmail.com
Tue Sep 28 12:21:53 EDT 2010

Hi ,

You can use this:

kill -9 `netstat -antp|grep 8080|grep java|awk '{ print $7 }'|cut -d'/' -f

But if had to do the same thing I would search in the running processes
instead using netstat, anyway you can extract the pid in the same way.


On Tue, Sep 28, 2010 at 7:14 PM, Carlos S <neubyr at gmail.com> wrote:

> I am writing a small script to kill process(es) listening on
> particular port number. Here I am particularly looking at Java
> servlet-containers like Tomcat and JBoss, which sometimes don't
> complete their shutdown process and it still shows up as running
> process with ps or netstat. This needs to be kill-ed and for that
> knowing pid of that process is necessary. The netstat by default
> doesn't give only pid(s), so one has to use sed/awk/tr like utility to
> extract pid info. Does anyone know any program/utility which gives
> pid(s) based on listening port numbers? Or is there any option in
> netstat that I am missing?
> Thanks,
> CS.
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.centos.org/pipermail/centos/attachments/20100928/06a83d1c/attachment.html 

More information about the CentOS mailing list