Shell script achieves precise cleanup squid cache _linux Shell

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.