我想杀死一个特定的进程(这是一个名为test.exe的程序)。 要做到这一点,我可以键入:
ps aux | grep test.exe
接着:
kill -9 process_id_of_test_exe
正如你所看到的,我需要多次input命令(而不是立即)。 问题是如何在一个命令中做到这一点。 采取test.exe的process_id并给予杀。 我觉得在这种情况下我需要写一个脚本。 谢谢。
使用此命令获取PID
pidof test.exe 1044
然后杀了它:
kill 1044
然后加入他们:
kill $(pidof test.exe)
你也可以使用你的命令:
kill -9 $(ps aux | grep [t]est.exe)
[t]
防止grep
自己。
尝试:
killall test.exe
看到man killall
更多的细节!
你可以像下面这样将kill -9和pgrep结合起来:
杀-9`pgrep test.exe`
为了杀死关键字test.exe
所有进程,请尝试
pkill -9 -f test.exe