To monitor which process is using swap, you can use the top command:
Log in to Advanced shell (bash).
Type the following command to enter the top utility:
# top
[root@unixonline]# top top - 01:10:24 up 230 days, 9:05, 9 users, load average: 0.00, 0.01, 0.05 Tasks: 220 total, 1 running, 219 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 8173900 total, 208380 free, 1598880 used, 6366640 buff/cache KiB Swap: 0 total, 0 free, 0 used. 5833596 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 24275 dirsrv 20 0 1081116 170152 44012 S 0.3 2.1 1198:56 ns-slapd 31097 root 20 0 162104 2352 1592 R 0.3 0.0 0:00.02 top 1 root 20 0 191372 4416 2616 S 0.0 0.1 80:15.97 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:15.50 kthreadd 4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:+ 6 root 20 0 0 0 0 S 0.0 0.0 2:34.12 ksoftirqd/0 7 root rt 0 0 0 0 S 0.0 0.0 0:52.99 migration/0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root 20 0 0 0 0 S 0.0 0.0 24:10.74 rcu_sched 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-dr+ 11 root rt 0 0 0 0 S 0.0 0.0 1:33.41 watchdog/0 12 root rt 0 0 0 0 S 0.0 0.0 1:17.54 watchdog/1 13 root rt 0 0 0 0 S 0.0 0.0 0:34.23 migration/1 14 root 20 0 0 0 0 S 0.0 0.0 2:10.22 ksoftirqd/1 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:+ 17 root rt 0 0 0 0 S 0.0 0.0 1:15.58 watchdog/2 18 root rt 0 0 0 0 S 0.0 0.0 0:28.49 migration/2
Press f to edit the columns display.
Press down to navigate down to the SWAP = Swapped Size (KiB) row.
Press right to select it for move.
Press up to move SWAP = Swapped Size (KiB) just directly above the COMMAND = Command Name/Line row.
Press Enter to commit.
Press space to add SWAP = Swapped Size (KiB) as a column to the top output. You may observe an additional * next to SWAP similar to the following example:
- SWAP = Swapped Size (KiB)
- COMMAND = Command Name/Line
Press Esc to exit edit mode.
Press shift+w to save the changes to the ~/.toprc file(top’s Config File). You may observe a momentary message similar to the following:
Wrote configuration to ‘/root/.toprc’
[root@unixonline]# ls -al .toprc -rw-r--r-- 1 root root 966 Dec 18 01:12 .toprc
The next time you start top, the swap column is displayed according to the settings in .toprc file.
[root@unixonline]# top top - 01:14:37 up 230 days, 9:10, 9 users, load average: 0.00, 0.01, 0.05 Tasks: 219 total, 1 running, 218 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 2.9 sy, 0.0 ni, 97.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 8173900 total, 210268 free, 1596928 used, 6366704 buff/cache KiB Swap: 0 total, 0 free, 0 used. 5835556 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ SWAP 31317 root 20 0 162104 2284 1560 R 6.2 0.0 0:00.02 0 1 root 20 0 191372 4416 2616 S 0.0 0.1 80:16.02 0 2 root 20 0 0 0 0 S 0.0 0.0 0:15.50 0 4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 0 6 root 20 0 0 0 0 S 0.0 0.0 2:34.17 0 7 root rt 0 0 0 0 S 0.0 0.0 0:52.99 0 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 0 9 root 20 0 0 0 0 S 0.0 0.0 24:10.75 0 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 0 11 root rt 0 0 0 0 S 0.0 0.0 1:33.41 0 12 root rt 0 0 0 0 S 0.0 0.0 1:17.54 0 13 root rt 0 0 0 0 S 0.0 0.0 0:34.23 0 14 root 20 0 0 0 0 S 0.0 0.0 2:10.22 0 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 0 17 root rt 0 0 0 0 S 0.0 0.0 1:15.58 0 18 root rt 0 0 0 0 S 0.0 0.0 0:28.49 0 19 root 20 0 0 0 0 S 0.0 0.0 0:21.53 0