ps is a very useful tool to list all current running processes with various info such as CPU usage, memory usage, process status, process id etc.
The common use of ps is to list all executing processes in user-oriented format.
To the extend of checking the “target” processes, let say “fluxbox”, we do this,
ps aux | grep fluxbox
With that, the lines with keyword “fluxbox” will be grepped. But, the first line of ps which use to display the field caption will be lost.
Output looks like this:
mysurface 4491 0.0 1.4 23516 7256 ? Ss 21:15 0:02 /usr/bin/fluxbox mysurface 5962 0.0 0.1 2800 768 pts/0 S+ 21:51 0:00 grep fluxbox
You probably can remember which field indicate what, but I can’t. I couldn’t remember the value 1.4 is what. Furthermore, the last line, “grep fluxbox”, is not what I targeted.
As long as you know the exactly you want, you can use the command line as bellow:
ps u -C fluxbox
Same way I want it to be user-oriented and I ask ps to give me only my targeted “process”.
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND mysurface 4491 0.0 1.4 23516 7256 ? Ss 21:15 0:02 /usr/bin/fluxbox
Neat and nice isn’t it? Thanks to bytee for the tip.
You can place a list of targeted processes. But bare in mind, its not like grep, you have put the exact process name.
ps u -C fluxbox,gaim,xchat
At last, you wanna monitor these command list, that is where watch take place,
watch -n 1 "ps u -C fluxbox,gaim,xchat"
-n is to specify the time interval, execute the line every 1 second. Ctrl+c to quit watch.