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
3 days 16 hours ago
6 days 7 hours ago
1 week 2 days ago
1 week 2 days ago
1 week 2 days ago
1 week 2 days ago
2 weeks 3 hours ago
2 weeks 1 day ago
2 weeks 1 day ago
3 weeks 1 day ago