Posts

Showing posts from November, 2021

Find Which Processes are Using Swap

I was doing s ome testing on my Virtuozzo linux VPS and wanted to find what was using the swap. The short version is that processes that have not been used in a long time will be moved into swap to free up RAM. I found the following page with a one-liner to show the running processes and the amount of swap they are using (including processes with 0 kB of swap).  https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/  I modified the one-liner to only show processes using swap. for file in $(grep -El "VmSwap:\s+[1-9][[:digit:]]* kB" /proc/*/status) ; do awk '/Name:|VmSwap:/{printf $2 " " $3}END{ print "" }' $file; done | sort -k2nr php-fpm 488792 kB php-fpm 485172 kB php-fpm 475640 kB php-fpm 469504 kB php-fpm 469100 kB php-fpm 462044 kB php-fpm 439604 kB php-fpm 430868 kB php-fpm 410124 kB php-fpm 389892 kB php-fpm 381132 kB php-fpm 380136 kB php-fpm 379988 kB php-fpm 379216 kB php-fpm 316296 kB mysqld 225884 kB php-fpm 92096 kB php-fpm 91