
很多時候我想終止我認為已更改其命令名稱的進程(我想通了setproctitle()
或類似的事情)。
顯然pkill
、pgrep
、 和朋友們不會讀取新的命令名稱(即 ruby 進程重命名其命令,pkill 仍然將其視為ruby
而不是delayed_job
)。
然而ps
並h?top
做。
我唯一的手段是 grep/awkingps
來殺死這些類型的進程還是我錯過了一些東西?
答案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.