Linux的/ bash中,用ps -o由特定名称获取进程? [英] Linux / Bash, using ps -o to get process by specific name?

查看:177
本文介绍了Linux的/ bash中,用ps -o由特定名称获取进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用-o命令获得匹配某个名字的进程只是特定信息的PS。不过,我有这方面的一些问题,当我尝试使用此,即使是拿到所有进程,就像这样,它只是返回什么正常的 PS -ef 将返回(所以它不是返回所有正在运行的进程,它不返回几乎相同数量的结果)

I am trying to use the ps -o command to get just specific info about processes matching a certain name. However, I am having some issues on this, when I try to use this even to just get all processes, like so, it just returns a subset of what a normal ps -ef would return (it doesn't return nearly the same number of results so its not returning all running processes)

ps -ef -o pid,time,comm

我想尝试这样的事情(下同),但纳入PS -o只是从它(只是PID)得到具体的信息

I want to try something like this (below) but incorporate the ps -o to just get specific info from it (just the PID)

ps -ef |grep `whoami`| grep firefox-bin

任何意见是AP preciated至于如何做到这一点正确,谢谢

Any advice is appreciated as to how to do this properly, thanks

推荐答案

这将让你的PID进程按名称:

This will get you the PID of a process by name:

pidof name

然后你就可以插回到ps的更多细节:

Which you can then plug back in to ps for more detail:

ps -p $(pidof name)

这篇关于Linux的/ bash中,用ps -o由特定名称获取进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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