RUVIDEO
Поделитесь видео 🙏

Unix & Linux: Sorting down processes by memory usage (8 Solutions!!)

Unix & Linux: Sorting down processes by memory usage


The Question: I am able to see the list of all the processes and the memory via
ps aux
and going through the VSZ and RSS
Is there a way to sort down the output of this command by the descending order
on RSS value?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 27 people ==
A quick and dirty method is to just pipe the output of ps aux to the sort
command:
$ ps aux | sort -rn -k 5,6
**** Example ****
$ ps aux | sort -rn -k 5,6
...
root 1584 0.0 0.0 22540 1236 ? S 07:04 0:01 hald-addon-
storage: polling /dev/sr0 (every 2 sec)
root 1575 0.0 0.0 22536 872 ? S 07:04 0:00 /usr/libexec/
hald-addon-generic-backlight
root 1574 0.0 0.0 22536 880 ? S 07:04 0:00 /usr/libexec/
hald-addon-leds
root 1565 0.0 0.0 22536 876 ? S 07:04 0:00 /usr/libexec/
hald-addon-rfkill-killswitch
saml 2507 0.0 0.0 22232 500 ? S 07:05 0:00 dbus-launch --
sh-syntax --exit-with-session
root 1671 0.0 0.0 22156 936 ? Ss 07:04 0:00 xinetd -
stayalive -pidfile /var/run/xinetd.pid
...
This doesn't handle for the column headers which get mixed in with the output,
but it's easy to remember on the command line, and is an acceptable way to do
what you want when manually viewing this type of output.
**** Example ****
root 1791 0.0 0.0 4140 536 tty2 Ss+ 07:04 0:00 /sbin/mingetty
/dev/tty2
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 996 0.0 0.0 0 0 ? S 07:04 0:01 [kdmflush]
root 982 0.0 0.0 0 0 ? S 07:04 0:00 [kvm-irqfd-
clean]
**** More tips ****
An additional tip would be to pipe the entire output to another command such as
less. This allows you to look at the information a page at a time and also use
the arrow keys and page up/down keys to scroll back and forth through the
output.
$ ps aux | sort -rn -k 5,6 | less
If your output is wrapping a lot you can also utilize the -S switch to less,
which will force all the output to stay on a single line instead. You can then
use your arrow keys to move left/right/up/down to see all of it.
$ ps aux | sort -rn -k 5,6 | less -S
**** Sorting within ps ****
Certain versions of ps provide the ability to use --sort. This switch can then
take keys that are either prefixed with a + or a - to denote the sort
order...least to greatest or greatest to least.
**** Examples ****
vsz,-rss
$ ps aux --sort=vsz,-rss | head -5
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S 07:03 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 07:03 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 07:03 0:01 [migration/0]
root 5 0.0 0.0 0 0 ? S 07:03 0:00 [watchdog/0]
+vsz,+rss
$ ps aux --sort=+vsz,+rss | head -5
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S 07:03 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 07:03 0:00 [ksoftirqd/0]
root 4 0.0 0.0 0 0 ? S 07:03 0:01 [migration/0]
root 5 0.0 0.0 0 0 ? S 07:03 0:00 [watchdog/0]
-vsz,-rss
$ ps aux --sort=-vsz,-rss | head -5
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1832 0.0 0.0 2088924 3312 ? Sl 07:04 0:00 /usr/sbin/
console-kit-daemon --no-daemon
saml 3517 0.2 1.2 2073196 100492 ? Sl 07:06 0:34 /home/
saml/.dropbox-dist/dropbox
saml 3516 0.0 0.8 2071032 67388 ? Sl 07:06 0:07 /home/
saml/.dropbox-dist/dropbox
saml 2657 0.1 0.7 1580936 57788 ? Sl 07:05 0:27 nautilus

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user user30747 (https://unix.stackexchange.com/users/82353), user user2817836 (https://unix.stackexchange.com/users/48005), user slm (https://unix.stackexchange.com/users/7453), user Sabrina (https://unix.stackexchange.com/users/264359), user Pierozi (https://unix.stackexchange.com/users/244816), user jturi (https://unix.stackexchange.com/users/269312), user gaoithe (https://unix.stackexchange.com/users/74372), user coffeMug (https://unix.stackexchange.com/users/28650), user Ayyanar (https://unix.stackexchange.com/users/215513), user 7ochem (https://unix.stackexchange.com/users/52721), and the Stack Exchange Network (http://unix.stackexchange.com/questions/92493). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Unix & Linux: Sorting down processes by memory usage (8 Solutions!!)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.