This script was modified on the cache cleanup script of Zhang banquet, mainly to add the if option, and select the address of the cached file based on the $1 parameter type (because $1 is not fixed, sometimes it is a specific JPG type, sometimes it is a domain name) currently, it is applied on your own Squid cache server and it seems that there is basically no error in the collection cache URL. You are welcome to try it out and strive to make this script more perfect (this script is used in centos5.4 x86_64, through squid2.7) the script content is as follows:
- #! /Bin/sh
- Squidcache_path = "/usr/local/squid/var/cache"
- Squidclient_path = "/usr/local/squid/bin/squidclient"
- # Grep-a-r $1 $ squidcache_path/* | strings | grep "http:" | awk-F 'HTTP: ''{print" http: "$2 ;} '| awk-f \ ''{print $1}'> cache.txt
-
- If [["$1" = "SWF" | "$1" = "PNG" | "$1" = "jpg" | "$1" = "ICO" | "$1" = "GIF" | "$1" = "CSS" | "$1" = "JS" | "$1" = "html" | "$1" = "shtml" | "$1" = "htm"]; then
- Grep-a-r. $1 $ squidcache_path/* | strings | grep "http:" | awk-F 'HTTP: ''{print" http: "$2 ;} '| awk-f \ ''{print $1}' | grep" $1 $ "| uniq> cache.txt
- Else
- Grep-a-r $1 $ squidcache_path/* | strings | grep "http:" | awk-F 'HTTP: ''{print" http: "$2 ;} '| awk-f \ ''{print $1}' | uniq> cache.txt
- Fi
-
- Cat cache.txt | while read line
- Do
- $ Squidclient_path-P 80-M purge $ line
- Done
This article from the "fuqin liquor" blog, please be sure to keep this source http://blog.chinaunix.net/uid-12924167-id-3193164.html