Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 杀死';ps aux&x27;一行输出_Linux_Macos_Ssh_Command Line_Ps - Fatal编程技术网

Linux 杀死';ps aux&x27;一行输出

Linux 杀死';ps aux&x27;一行输出,linux,macos,ssh,command-line,ps,Linux,Macos,Ssh,Command Line,Ps,我每天要做很多次同样的事情: ps aux 查找运行ssh到我的一个服务器的进程 kill -9 <pid> 我总是想用my server终止进程 有人知道我如何做到这一点吗?一个简单的解决方案是: 一个简单的解决方案是使用: 用于pid(ps aux|grep“[m]y-server”|awk'{print$2}”);杀死-9美元pid;完成 ps aux|grep“[m]y-server”|awk'{print$2}'-此部分为您提供包含“我的服务器”的pids进程列表。这个

我每天要做很多次同样的事情:

ps aux
查找运行ssh到我的一个服务器的进程

kill -9 <pid>
我总是想用
my server
终止进程


有人知道我如何做到这一点吗?

一个简单的解决方案是:


一个简单的解决方案是使用:

用于pid(ps aux|grep“[m]y-server”|awk'{print$2}”);杀死-9美元pid;完成

ps aux|grep“[m]y-server”|awk'{print$2}'-此部分为您提供包含“我的服务器”的pids进程列表。这个脚本将遍历这个列表并终止所有进程

用于pid,单位为美元(ps aux | grep“[m]y-server”| awk'{print$2});杀死-9美元pid;完成

ps aux|grep“[m]y-server”|awk'{print$2}'-此部分为您提供包含“我的服务器”的pids进程列表。这个脚本将遍历这个列表并终止所有进程

我使用pgrep——如果您确定要终止所有匹配的进程:

$ kill -9 `pgrep my-server`
我使用pgrep——如果您确定要终止所有匹配的进程:

$ kill -9 `pgrep my-server`

因此,我简化了
ps aux
输出,实际上,ssh与
my server
一个服务器在同一行中插入了更多的服务器。这仍然有效吗?因此我简化了
ps aux
输出,实际上,ssh与
my server
一个服务器在同一行中插入了更多的服务器。这还能用吗?
$ kill -9 `pgrep my-server`