
コマンド名が変更されたと思われるプロセスを終了したい場合がよくあります(よく考えたりsetproctitle()
、似たようなことをしたり)。
明らかにpkill
、、pgrep
および の仲間は新しいコマンド名を読み取らない (つまり、 プロセスがコマンドの名前を変更しても、pkill はそれをruby
ではなくとして認識しますdelayed_job
)。
しかしps
、そうh?top
します。
ps
こうした種類のプロセスを強制終了するには、grep/awking するしか方法がありませんか、それとも何か見落としているのでしょうか?
答え1
ps -f
、pgrep -f
、を使用してみてくださいpkill -f
。
それぞれのマニュアルページから:
ps -f
Do full-format listing. This option can be combined with many
other UNIX-style options to add additional columns. It also
causes the command arguments to be printed.
-
pgrep/pkill -f, --full
The pattern is normally only matched against the process name.
When -f is set, the full command line is used.