この質問にはすでに回答があります :Ubuntuでプロセスを強制終了するにはどうすればよいですか?
(12の回答)
5年前に閉鎖されました。
Ubuntu
(12の回答)
5年前に閉鎖されました。
myNameを含むプロセスを強制終了する必要があります その説明で。現在私が行っていること:
ps -ax |grep myName
I see PID
kill -9 PID
PIDを入力せずに1つのコマンドで同じことを行うにはどうすればよいですか?
承認された回答:
myNameの場合 強制終了するプロセス/実行可能ファイルの名前です。次を使用できます:
pkill myName
pkill デフォルトでは、SIGTERMを送信します 信号(信号15)。 SIGKILLが必要な場合 またはシグナル9、使用:
pkilll -9 myName
myNameの場合 はプロセス名ではないか、たとえば、別の(長い)コマンドpkillへの引数です (またはpgrep )期待どおりに機能しない可能性があります。したがって、-fを使用する必要があります オプション。 man killから :
-f, --full
The pattern is normally only matched against the process name.
When -f is set, the full command line is used.
NOTES
The process name used for matching is limited to the 15 characters present
in the output of /proc/pid/stat. Use the -f option to match against the
complete command line, /proc/pid/cmdline.
だから:
pkill -f myName
または
kill -9 $(pgrep -f myName)