This script was modified on the Zhang Yi cache cleanup Script, the main is to add the IF option and optionally list the address of the cache file based on the parameter type (because it is not fixed, sometimes a particular JPG type, sometimes a domain name), is currently applied on its own Squid cache server. Sensory Acquisition Cache URL basically no error, welcome to try to make this script more perfect (this script is passed under Centos5.4 x86_64,squid2.7) script content as follows:
Copy Code code as follows:
#!/bin/sh
Squidcache_path= "/usr/local/squid/var/cache"
Squidclient_path= "/usr/local/squid/bin/squidclient"
if [["$ =~ swf|png|jpg|ico|gif|css|js|htm|html|shtml]]; Then
Grep-a-R. $ $squidcache _path/* | Strings | grep "http:" | Awk-f ' http: ' {print ' http: ' $} ' | Awk-f\ ' {print $} ' > Cache.txt
Else
GREP-A-R $ $squidcache _path/* | Strings | grep "http:" | Awk-f ' http: ' {print ' http: ' $} ' | Awk-f\ ' {print $} ' > Cache.txt
Fi
While Read line
Todo
$squidclient _path-h 122.70.148.51-p 80-m PURGE $LINE
Done < Cache.txt