Tuesday, 24 April 2018

How to find swap memory utilizing processes in a Linux machine

Top command:

Type the top command as root:
# top

To sort process as per swap page usage (SWAP = VIRT – RES) type capital O (option) followed by p (small p) and [Enter] key:


Single line script to find out the processes consuming high swap memory.

The following script will be useful in finding the process which is utilizing high swap.

------
(echo "COMM PID SWAP"; for file in /proc/*/status ; do awk '/^Pid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | grep -wv "0 kB" | sort -k 3 -n -r) | column -t
---------

Reference:
-----------
https://www.tecmint.com/commands-to-monitor-swap-space-usage-in-linux/
https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/
------------

No comments:

Post a comment

Note: only a member of this blog may post a comment.