您现在的位置是:网站首页> 编程资料编程资料
Shell脚本实现精准清除Squid缓存_linux shell_
2023-05-26
396人已围观
简介 Shell脚本实现精准清除Squid缓存_linux shell_
此脚本是在张宴的缓存清理脚本上做了修改的,主要是增加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脚本中使用for循环和cat命令实现按顺序合并文件_linux shell_
- Shell脚本实现监控iptables运行状态_linux shell_
- Shell脚本实现监控rsync数据是否传输完_linux shell_
- Shell脚本实现监控kingate并自动启动_linux shell_
- Shell脚本实现监控iptables规则是否被修改_linux shell_
- expect实现单台、多台服务器批量scp传输文件_linux shell_
- Shell脚本实现关闭多余的tty终端_linux shell_
- Shell脚本中实现切换用户并执行命令操作_linux shell_
- Shell脚本自动删除指定大小以上的备份文件_linux shell_
- Shell脚本实现批量替换文件内容_linux shell_
