使用 bash/terminal 进行进程管理
快速 bash/终端问题 -
我在命令行上工作很多,但从来没有真正了解如何用它管理正在运行的进程 - 我知道“ps”,但它总是给我一个非常长和深奥的问题垃圾列表,包括大约 30 名 google chrome 工作人员,我总是最终回到活动监视器以清楚地了解实际发生的情况。
任何人都可以提供一些有关如何从命令行管理正在运行的进程的建议吗?有没有办法获得您正在运行的内容的干净列表?我经常在进程名称上使用“killall”,我知道这是摆脱冻结的东西的快速方法 - 我可以让这些名称通过终端显示,而不是 ps 默认显示的奇怪的长名称和数字吗?我可以搜索特定进程或进程的快速正则表达式,例如“*ome”吗?
如果有人知道这三个问题的答案,那将对很多人有很大的帮助,我相信:)
谢谢!
Quick bash/terminal question -
I work a lot on the command line, but have never really had a good idea of how to manage running processes with it - I am aware of 'ps', but it always gives me an exceedingly long and esoteric list of junk, including like 30 google chrome workers, and I always end up going back to activity monitor to get a clean look at what's actually going on.
Can anyone offer a bit of advice on how to manage running processes from the command line? Is there a way to get a clean list of what you've got running? I often use 'killall' on process names that I know as a quick way to get rid of something that's freezing up - can I get those names to display via terminal rather than the strange long names and numbers that ps displays by default? And can I search for a specific process or quick regex of a process, like '*ome'?
If anyone has the answers to these three questions, that would be amazingly helpful to many people, I'm sure : )
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的 grep 很好。
我不知道你想实现什么,但你知道 top 命令吗? Il 为您提供正在发生的事情的动态视图。
在 Linux 上,您有大量的命令可以帮助您在脚本中获得所需的内容,而管道命令是我们在学习 IT 时学到的基础知识。
您还可以看看 man of jobs,我建议您阅读一些有关流程管理基础知识的文章。 :)
祝你好运。
Yes grep is good.
I don't know what you want to achieve but do you know the top command ? Il gives you a dynamic view of what's going on.
On Linux you have plenty of commands that should help you getting what you want in a script and piping commands is a basic we are taught when studying IT.
You can also get a look to the man of jobs and I would advise you to read some articles about process management basics. :)
Good Luck.
将为您提供仅包含进程名称的列表(更准确地说,是调用该进程的命令)。使用grep进行搜索,如下所示:
will give you a list of just the process names (more exactly, the command that invoked the process). Use grep to search, like this:
那里可能有脚本..
但是例如,如果您看到很多您不感兴趣的镶边,那么像下面这样简单的东西会有所帮助:
其他变体可以帮助仅显示每个图像一次...所以你会得到一个 chrome、一个 vim 等..(例如,google 用 perl 或 python 或 sed 显示唯一的行)
你可以使用 ps 指定一个用户名...这样你就可以过滤掉系统进程,或者如果登录了多个用户到机器等。
Ps 的用途非常广泛命令行参数.. 一点点挖掘有助于找到许多与其他工具(如 perl 和 sed 等)结合的不错的调整和标志。
there may be scripts out there..
but for example if you're seeing a lot of chrome that you're not interested in, something as simple as the following would help:
other variations could help showing each image only once... so you get one chrome, one vim etc.. (google show unique rows with perl or python or sed for example)
you could use ps to specifiy one username... so you filter out system processes, or if more than one user is logged to the machine etc.
Ps is quite versatile with the command line arguments.. a little digging help finding a lot of nice tweaks and flags in combinations with other tools such as perl and sed etc..