每隔10分钟查看xxx进程的内存使用 并发送到指定的tftp server
#!/bin/sh
#spilt pid of current process xxx
pid=`ps |grep xxx|awk 'NR==1 {print $1}'`
echo $pid
BLANK=
#timeout is 600 seconds
TIMEOUT=600
#loop until we kill it
while true
do
#catch current time
DATE=`date +%H:%M:%S-%Y-%m-%d`
#write current time to log.dat
echo $DATE >> log.dat
#write mem info to log.dat
cat /proc/$pid/status|grep -e VmRSS >> log.dat
#write a enter to log.dat
echo $BLANK >> log.dat
#every 10 minutes put it to remote tftp server(for example 192.168.14.23)
tftp -l log1450.dat -p 192.168.14.23
sleep $TIMEOUT
done
获取某进程 内存使用量 shell脚本
最新推荐文章于 2023-05-05 09:31:38 发布