杀死名随机过程 [英] Kill random process with name

查看:179
本文介绍了杀死名随机过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想办法杀死一个名称随机过程(例如:随机perl的进程)。

I want a way to kill a random process with a name (eg a random perl process).

什么是这样做的最佳方式?

What would be the best way of doing this?

我是thinkign使用类似这样的:

I was thinkign of using something like this:

ps aux | grep PROCESS-NAME

到一个文件,然后找到一个随机的行号,拿到第二列(进程ID?)并杀死。

to a file, then find a random line number, get the second column (process ID?) and kill that.

有关我的使用它实际上并不需要是一个随机的,只要它杀死的过程之一。使得它随机只令它变得更好。

For my use it doesn't actually need to be a random one, as long as it kills one of the processes. Making it random just makes it better.

推荐答案

猛砸单行:-P

kill `ps auxww | grep zsh | awk '{print $2}' | while read line; do echo "$RANDOM $line"; done | sort | cut -d ' ' -f 2 | head -n 1`

这篇关于杀死名随机过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆