業界トップクラスの求人数を誇る転職エージェントPR

リクルートグループのコネクションを活かした非公開求人も充実、他にはない好条件の求人と出会える

125
97

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

プロセス名でgrepした結果をkillするシェルスクリプトを作る

Posted at
ps aux | grep [プロセス名] | grep -v grep | awk '{ print "kill -9", $2 }' | sh

対象のプロセス名を抽出し、grep -vで結果からgrep自身を除外。
最後にawkで結果のPIDを元にkill -9 PIDという文字列を生成。

生成した結果をシェル側に渡してやり実行する。

長時間動き続けるプロセスを定期的にkillして再起動させたい時などご活用ください。

125
97
2

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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
125
97

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?