There's already a good answer to the question at
stackoverflow. They suggested to use the
top command, then change the sorting field to "swap" by hitting
O and
p. Unfortunately (afaik) there's no way to do this in batch mode (using the
-b switch) and save the top swap using prorcesses in a file. There's another method: use the
ps command.
psres=$(ps -eo rss,vsz,user,pid,tty,time,cmd); set -- $(/bin/echo "$psres" | head -n1); shift; shift; echo "SWAP $*"; echo "$psres" | awk 'BEGIN {ORS=""; getline} {print $2 - $1 " "; for (i=3; i<NF; i++) print $i " "; print $NF "\n"}' | sort -rn | head
Recent comments
5 days 17 hours ago
1 week 1 day ago
1 week 4 days ago
2 weeks 9 hours ago
2 weeks 10 hours ago
2 weeks 10 hours ago
2 weeks 10 hours ago
2 weeks 4 days ago
2 weeks 6 days ago
2 weeks 6 days ago