2016-10-11 70 views
0
端口

我目前其默認端口上運行RethinkDB,因爲如果我點我的瀏覽器localhost:8080我看到RethinkDB Web界面:如何確定是哪個進程在Linux中使用

enter image description here

我想要關閉RethinkDB並使用--port-offset參數在另一個端口上重新打開它。但是,到目前爲止,我還無法使用conn.close()方法在Python中關閉它。

相反,我想通過簡單地使用該端口來終止進程來嘗試一種強力方法。我試圖確定哪些過程,是通過使用netstat,但並不會彈出任何結果:

[email protected]:~$ netstat -a | grep 8080 
[email protected]:~$ 

我怎麼能殺RethinkDB進程,使再次可用的端口?

+1

'netstat的-nlp'運行。最好用'sudo'! –

回答

4
1. lsof -i:8080 
2. kill $(lsof -t -i:8080) 
or 
2 . kill -9 $(lsof -t -i:8080) 
0

Klaus D.的評論,我決定使用netstat -nlp過程:

[email protected]:~$ netstat -nlp | grep 8080 
(Not all processes could be identified, non-owned process info 
will not be shown, you would have to be root to see it all.) 
tcp  0  0 127.0.1.1:8080   0.0.0.0:*    LISTEN  2229/rethinkdb 
tcp  0  0 127.0.0.1:8080   0.0.0.0:*    LISTEN  2229/rethinkdb 
tcp6  0  0 ::1:8080    :::*     LISTEN  2229/rethinkdb 

的參數代表

  • numeric(展示,而不是試圖確定符號主機的數字地址,端口或用戶名)
  • listening(只顯示監聽套接字(本身是由默認值))
  • program省略(示出了PID和分別

到每個插座所屬的節目的名稱)。

0

真棒回答@codespy。 我做了一個bash文件,並像這樣寫下來。 !

/斌/慶典

殺$(lsof的-t -i:8000)

,並保存和腳本文件。

而且通過 $搭配chmod做出可執行+ X SCRIPT_FILENAME

我現在就可以通過輸入 ./script_filename

相關問題