首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >linux查看cache占用

linux查看cache占用

原创
作者头像
用户1168904
修改于 2021-05-18 10:06:03
修改于 2021-05-18 10:06:03
7.4K0
举报
文章被收录于专栏:运维相关文档运维相关文档

需要下载pcstat

[root@xk-1-145-a8 ~]# cat pcstat.sh

#!/bin/bash

#you have to install pcstat

if [ ! -f /root/pcstat.x86_64 ]

then

echo "You haven't installed pcstat yet"

echo "run \"go get github.com/tobert/pcstat\" to install"

exit

fi

#find the top 10 processs' cache file

ps -e -o pid,rss|sort -nk2 -r|head -10 |awk '{print $1}'>/tmp/cache.pids

#find all the processs' cache file

#ps -e -o pid>/tmp/cache.pids

if [ -f /tmp/cache.files ]

then

echo "the cache.files is exist, removing now "

rm -f /tmp/cache.files

fi

while read line

do

lsof -p $line 2>/dev/null|awk '{print $9}' >>/tmp/cache.files

done</tmp/cache.pids

if [ -f /tmp/cache.pcstat ]

then

echo "the cache.pcstat is exist, removing now"

rm -f /tmp/cache.pcstat

fi

for i in `cat /tmp/cache.files`

do

if [ -f $i ]

then

echo $i >>/tmp/cache.pcstat

fi

done

/root/pcstat.x86_64 `cat /tmp/cache.pcstat`

#rm -f /tmp/cache.{pids,files,pcstat}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档