how to release port

how to release port

有一支process ,莫名奇妙的死掉

但是他所對應的port卻沒有release netstat 還可以看到被咬著

這樣會導致我的process 就沒辦法在重起

有辦法強迫release port嗎

在linux可以用下列方式看到是哪一支process 在用該port

netstat -tupln |grep ""可以看到對應port的process

4 回覆

how to release port

Hi :

if you have lsof installed, you can use it to find out which process is opening the desired port number.



Such as, if I like to find out who is using port number 25, then I do this,

#lsof -i :25



COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

sendmail 3440 root 5u inet 0x45a56b80 0t0 TCP *:smtp (LISTEN)



.

..

how to release port

you can get lsof at following URL.



http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.76/

how to release port

最近剛好碰到類似的問題, 不過我們是要在不砍掉process的

情況下, force terminate tcp connection(release

port).



請參考附檔, 把netstat -an那行後面的字串替換成你要砍的

session. 然後



#perl killtcpconn.pl

#netstat -an|grep ~ 再次確認.



PS. 程式在english forum找到的.

how to release port