Script memory usage statistics

Script memory usage statistics

#!/bin/bash

count=0
for i in `ps aux |awk '{print $6}' |grep -v 'RSS'`
do
   # 将遍历出来的数字进行累加
   count=$[$count+$i]
done

# 就得到所有进程占用内存大小的和了
echo "$count/kb"

Form with awk

ps aux |grep -v 'RSS TTY' |awk '{sum=sum+$6};END{print sum}'
Published 147 original articles · won praise 27 · views 8439

Guess you like

Origin blog.csdn.net/weixin_46108954/article/details/104827351