Operating System - HP-UX
1819794 Members
3374 Online
109607 Solutions
New Discussion юеВ

Command to kill a port running on a particular network interface

 
SOLVED
Go to solution
Shivkumar
Super Advisor

Command to kill a port running on a particular network interface

Hi,

I have a process not showing up by various options of ps command. I saw it is listening on a particular port by "netstat an|grep i- listen" command. This listening port prevent the process while starting.

I was able to get the pid of the process few months ago on a different system using lsof and killed it.

I am facing similar situation on a machine where lsof is not installed.

Is there any way to execute lsof running on a different host ?

We have ssh running on both the machines. I tried couple of quick option but could not invoke lsof from different host.

Appreciate if anyone can provide correct syntax ?

Is there any command on Unix to kill a port running on a particular network IP interace ?

Thanks,
Shiv
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: Command to kill a port running on a particular network interface

Hi Shiv:

The installation of 'lsof' doesn't require a reboot, so why not download and install it on the machine missing it? It is one of those tools that every server should have. Finding the pid of a process associated with a port virtually requires 'lsof'.

http://hpux.connect.org.uk/hppd/cgi-bin/search?package=on&description=on&term=lsof

Regards!

...JRF...
Steven E. Protter
Exalted Contributor

Re: Command to kill a port running on a particular network interface

Shalom Shiv,

lsof must be installed on the system you are trying to kill the process on. System A can't get process table information on system B unless it remotely logs in.

Why not do this:
netstat -an | grep ":portnumber"

netstat -an | grep ":2504"

Then use that information to identify the process. You might not even need lsof to do it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Shivkumar
Super Advisor

Re: Command to kill a port running on a particular network interface

Hi Steven and James,

I do not have root access to that box. Can i install lsof with normal user account ?

Secondly, if i get the port number with netstat then which command will help in associating with port number ? I mean how do I trace the PID if port is known ?

Thanks and best regards,
Shiv
Dennis Handly
Acclaimed Contributor

Re: Command to kill a port running on a particular network interface

>I have a process not showing up by various options of ps command. I saw it is listening on a particular port by "netstat an|grep i- listen" command

This is just about impossible. Possibly for zombies. I suppose netstat could be reporting stale data?

>Can I install lsof with normal user account?

I wouldn't think so, it may use root to get the info it needs.

>I mean how do I trace the PID if port is known?

Searching ITRC for lsof and port gives:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=112311
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1139542
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=37108
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1102052