LoginSignup
0

More than 3 years have passed since last update.

特定のポート番号を使用するプロセスを一括killするワンライナー

Posted at

ゾンビプロセスを駆逐するワンライナー。

特定のポートを使用しているプロセスを調べる。

$ lsof -i:ポート番号
COMMAND   PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
ruby    37922 xxxx    xx  IPv4 xxxxxxx      xxx  TCP xxxxx:xxxxxx (ESTABLISHED)

PIDだけ出力する。

$ lsof -ti:ポート番号
37922

一括kill

$ lsof -ti:ポート番号 | xargs kill -9

参考にしたサイト

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0