此腳本是在張宴的緩存清理腳本上做了修改的,主要是增加if選項,并根據(jù)$1參數(shù)類型來選擇性的列出緩存文件所在地址(因為$1并不固定,有時是特定的jpg類型,有時是域名)目前在自己的Squid緩存服務(wù)器上應(yīng)用,感覺采集緩存網(wǎng)址基本上沒什么誤差了,歡迎大家試用,爭取將此腳本做到更加完美(此腳本在Centos5.4 x86_64,Squid2.7下通過)腳本內(nèi)容如下:
代碼如下:
#!/bin/sh
squidcache_path="/usr/local/squid/var/cache"
squidclient_path="/usr/local/squid/bin/squidclient"
if [[ "$1" =~ swf|png|jpg|ico|gif|css|js|htm|html|shtml ]]; then
grep -a -r .$1 $squidcache_path/* | strings | grep "http:" | awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' > cache.txt
else
grep -a -r $1 $squidcache_path/* | strings | grep "http:" | awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' > cache.txt
fi
while read LINE
do
$squidclient_path -h 122.70.148.51 -p 80 -m PURGE $LINE
done < cache.txt
更多信息請查看IT技術(shù)專欄