Linux: List processes by % cpu memory usage
With these two scripts you will see a rapid and simple processes sorted by use (%) CPU and memory. Of course it is not necessary (or practical) type the full command in the shell every time I run ye, I recommend create an aliasspecific for each of processes ellos.Listar % cpu, you will see that we eliminate those using 0.0 de CPU con thirst (sed ‘/^ 0.0 /d):
ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'
Example:
$ ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' %CPU CPU NI S TIME COMMAND 0.2 - 0 S 00:00:24 metacity 0.2 - 0 S 00:00:00 /usr/bin/python /usr/bin/terminator 0.2 - 0 S 00:00:28 gnome-screensaver 0.2 - 0 S 00:00:31 gnome-panel 4.6 - 0 S 00:08:23 /usr/bin/pulseaudio --start 7.4 - 0 S 00:13:24 /usr/X11R6/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth-nolisten tcp VT7 7.5 - 0 S 00:04:31 Rhythmbox 14.4 - 0 S 00:08:50 /usr/lib/firefox-3.5.4/firefox-3.5
List processes by memory usage (en KB):
ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
Example (reduced):
$ ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
23964 gnome-panel
26168 nautilus
26256 /usr/bin/python /usr/bin/terminator
58340 /usr/X11R6/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth-nolisten tcp VT7
58728 Rhythmbox
128736 /usr/lib/firefox-3.5.4/firefox-3.5
FUENTE: http://rm-rf.es/linux-listar-procesos-cpu-memoria /