Consider the following lines from a "ps auxwww"
output:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 4262 0.0 0,1 76592 1104 s005 Ss 10:02am 0:00.03 login -pf yo
yo 4263 0.0 0,0 75964 956 s005 S 10:02am 0:00.03 -bash
How do I force ps to expand all commands in the COMMAND column to their fully qualified path names? I want login to be resolved to /usr/bin/login and Bash to /bin/bash.
Is there an equivalent to procfs in Mac OS X? That is - is there a file-based mechanism to easily obtain process information?
Try this instead:
ps ax -o pid,cmd
You can reformat it as you wish (read the man page for details).
Finally, I think that ps (and even cat /proc/*/cmdline) will report the command the way it was launched. So if no full path was given, it will appear as just "command" instead of "/path/to/command".
Firstly, processes can change the title reported by
ps
, so it's not very reliable in itself. You could try the environment variables using the 'e' flag.Within these should be a builtin '_' variable as described here.
This holds true for
sh
on BSD as it does Linux. I believe that this can't overwritten by the user. However, its availability may depend on the user's choice of shell, it's pretty nasty and your mileage may vary.OS X doesn't have a native procfs. There is a port based upon FUSE. Details can be found here. Again, your mileage may vary.
Stop messing around with ps and use cat /proc/pid/cmdline .
You can use wildcards such as /proc/*/cmdline .
Extract all process ids and full path from /proc: