0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ps aux & grep の使い方

Posted at

目的

ps auxgrep を使って、あるプロセスが起動しているかどうかをチェックする。

方法

改善前

下記のように grep すると、grepコマンド自体のプロセスも検索されてしまう。
grep -E "air" というプロセス名が、grep -E "air" による検索に引っかかってしまうのである。厳密には、grep --color=auto -E airというプロセス名になっており、それが、grep -E "air" による検索に引っかかっている。

~/prashell$ ps aux | grep -E "air"
root      214089  0.0  0.0 1898556 14316 ?       Ssl  02:32   0:00 air -c .air.toml
yournam+  770002  0.0  0.0   4032  2092 pts/16   S+   14:06   0:00 grep --color=auto -E air

改善後

下記のように grep することで、grepコマンド自体のプロセスを検索に引っ掛けないことができる。
なぜなら、grep -E "[a]ir" というプロセス名は、grep -E "[a]ir"の検索には引っかからないからである。

~/prashell$ ps aux | grep -E "[a]ir"
root      214089  0.0  0.0 1898556 14316 ?       Ssl  02:32   0:00 air -c .air.toml
0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?