首页 > Web开发 > 详细

Shell脚本实现精准清除Squid缓存

时间:2016-01-15 22:21:45      阅读:141      评论:0      收藏:0      [点我收藏+]

此脚本是在张宴的缓存清理脚本上做了修改的,主要是增加if选项,并根据$1参数类型来选择性的列出缓存文件所在地址(因为$1并不固定,有时是特定的jpg类型,有时是域名)目前在自己的Squid缓存服务器上应用,感觉采集缓存网址基本上没什么误差了,欢迎大家试用,争取将此脚本做到更加完美(此脚本在Centos5.4 x86_64,Squid2.7下通过)脚本内容如下:

复制代码 代码如下:

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

Shell脚本实现精准清除Squid缓存

原文:http://www.jb51.net/article/59492.htm

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!