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

#!/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

你可能感兴趣的:(运维,linux)