views:

33

answers:

1

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

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

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

+6  A: 

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

pidof name

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

ps -p $(pidof name)
Alex Howansky
Whoops, sorry, missed that "just the PID" part, edited for clarity.
Alex Howansky
thanks, that is exactly what I was looking for
Rick
`pgrep` can also be used, but there are some differences in the way they work. For example, on my system running apache2, `pidof` will find "apache2" but not "apache" while `pgrep` will find it either way.
Dennis Williamson