监控进程内存使用情况脚本程序

#!/bin/bash

PROCESS=backEnd
LOG="./memlog.txt"

echo "$LOG"
#删除上次的监控文件
if [ -f "$LOG" ];then
    rm "$LOG"
fi

#过滤出需要的进程ID
PID=$(ps aux| grep $PROCESS | grep -v 'grep' | awk '{print $2;}')
echo "$PID"

while [ "$PID" != "" ]
do
    cat /proc/$PID/status | grep RSS >> "$LOG"
    sleep 60
    PID=$(ps aux| grep $PROCESS | grep -v 'grep' | awk '{print $2;}')
done

猜你喜欢

转载自blog.csdn.net/yunlilang/article/details/80636720
今日推荐