#!/bin/bash ps -C $1 -O rss | gawk '{ count ++; sum += $2 }; \ END {count --; print "Number of processes =",count; \ print "Memory usage per procsss =",sum/1024/count, "MB"; \ print "Total memory usage =", sum/1024, "MB" ;};'
[root@Linux29 ~]# ./mem.sh java Number of processes = 3 Memory usage per process = 153.672 MB Total memory usage = 461.016 MB [root@Linux29 ~]# ./mem.sh oracle Number of processes = 71 Memory usage per process = 47.5638 MB Total memory usage = 3377.03 MB
方便统计