ps 和 top 顯示的指令名稱與 pkill 和 pgrep 看到的指令名稱不同

ps 和 top 顯示的指令名稱與 pkill 和 pgrep 看到的指令名稱不同

很多時候我想終止我認為已更改其命令名稱的進程(我想通了setproctitle()或類似的事情)。

顯然pkillpgrep、 和朋友們不會讀取新的命令名稱(即 ruby​​ 進程重命名其命令,pkill 仍然將其視為ruby而不是delayed_job)。

然而psh?top做。

我唯一的手段是 grep/awkingps來殺死這些類型的進程還是我錯過了一些東西?

答案1

嘗試使用ps -f,pgrep -fpkill -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.

相關內容