forked from sangrealest/shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_cache.sh
More file actions
executable file
·50 lines (38 loc) · 925 Bytes
/
find_cache.sh
File metadata and controls
executable file
·50 lines (38 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
#Author: Shanker
#Time: 2016/06/08
#set -e
#set -u
#you have to install linux-fincore
if [ ! -f /usr/local/bin/linux-fincore ]
then
echo "You haven't installed linux-fincore yet"
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.fincore ]
then
echo "the cache.fincore is exist, removing now"
rm -f /tmp/cache.fincore
fi
for i in `cat /tmp/cache.files`
do
if [ -f $i ]
then
echo $i >>/tmp/cache.fincore
fi
done
linux-fincore -s `cat /tmp/cache.fincore`
rm -f /tmp/cache.{pids,files,fincore}