[swap] instantiate information about using swap processes
# for i in `cd / proc;ls | grep "^ [0-9]" | awk'$0 > 100' `; do awk'/ Swap:/ {a=a+$2} END {print'"$I", a proc/ 1024 "M"}'/ proc/ $I / smaps; done | sort-k2nr
#! / bin/bash
#
#
Echo-e "PID\ t\ tSwap\ t\ tProc_Name"
# take out all the directories named by numbers under the / proc directory (the process name is the number is the process, and other information such as sys,net is stored)
For pid in `ls-l / proc | grep ^ d | awk'{print $9}'| grep-v [^ 0-9] `
Do
# there is only one way for a process to release swap: restart the process. Or wait for it to be released automatically.
# if the process will be automatically released, then we will not write a script to find him, all because he did not automatically release.
# so we want to list the processes that take up swap and need to be restarted, but init is the ancestor of all processes in the system
# restarting the init process means restarting the system, which is absolutely impossible, so there is no need to test it so as not to affect the system.
If [$pid-eq 1]; then continue;fi # Do not check init process
# determine whether the modification process takes up swap
Grep-Q "Swap" / proc/$pid/smaps 2 > / dev/null
If [$?-eq 0]; then # if swap is occupied
# Total size of occupied swap (in KB)
Swap=$ (grep Swap / proc/$pid/smaps | awk'{sum+=$2;} END {print sum}')
# process name
Proc_name=$ (ps aux | grep-w "$pid" | grep-v grep | gawk'{for)