 |
 |
How do you grep for processes in OS X?
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
When I try the normal way I get an error:
Thaidogs-G4:/usr/sbin tylerm$ ps -ef | grep mysql
ps: illegal option -- f
usage: ps [-aChjlmMrSTuvwx] [-O|o fmt] [-p pid] [-t tty] [-U user]
[-N system] [-W swap]
ps [-L]
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
I usually use ps -acx
-a is "Display information about other users' processes as well as your own."
-c is "Change the ``command'' column output to just contain the executable name, rather than the full command line." If you don't do this or -ww, the name of the executable may be hidden because the path to it is too long.
-x is "Display information about processes without controlling terminals."
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
Originally posted by wataru:
I usually use ps -acx
-a is "Display information about other users' processes as well as your own."
-c is "Change the ``command'' column output to just contain the executable name, rather than the full command line." If you don't do this or -ww, the name of the executable may be hidden because the path to it is too long.
-x is "Display information about processes without controlling terminals."
So what would be the full command?
ps -acx | grep mysql ?
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Yes. The problem was that ps didn't like the -f tag for whatever reason. The rest is correct.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
ps -ef
is the common usage in the System V based unix world.
ps -ax
is the common usage in the BSD based unix world.
With the divergence of unix-y operating systems, some commands which are similar on the different versions do actually use different arguments for different things.
In some cases you may also find the the GNU versions of some commands (usually used in Linux distributions) may be different again, but in most cases they'd be based on either System V or BSD versions.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
I'm used to working on Solaris, AIX and Linux.... all of them that I have used use the ps -ef metaphor.... thanks for the explanation 
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
I usually use
ps -ax | grep foo
I was trying to refine this the other day - so exclude the 'grep foo' process from the list - but my Regex skills failed massively - and I couldn't work out how to exclude processes that contain "grep"
Anyone know how to do this?
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: May 2004
Status:
Offline
|
|
Yes, the BSD heritage of OSX is showing here! I use ps -ef on SYSV, and ps aux on BSD.
|
╭1.5GHz G4 15" PB, 2.0GB RAM, 128MB VRAM, 100GB 7200rpm HD, AEBS, BT kbd
╰2.0GHz T2500 20" iMac, 1.5GB RAM, 128MB VRAM, 250GB 7200rpm HD
http://www.DogLikeNature.com/
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Oct 2001
Location: Yokohama, Japan
Status:
Offline
|
|
Originally posted by Diggory Laycock:
I usually use
ps -ax | grep foo
I was trying to refine this the other day - so exclude the 'grep foo' process from the list - but my Regex skills failed massively - and I couldn't work out how to exclude processes that contain "grep"
Anyone know how to do this?
ps -ax | grep foo | grep -v grep
The -v flag returns all lines that don't match the search string.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Use either acux or auwwx otherwise you could miss it depending on the width of your terminal window 
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|