手机版
你好,游客 登录 注册
背景:
阅读新闻

支持多核SMP Squid3.2 缓存反向代理

[日期:2012-07-16] 来源:Linux社区  作者:rfyiamcool [字体:大 中 小]
清理缓存~~~

qingli.sh      www.xiuxiukan.com

qingli.sh      jpg

qingli.sh       xiuxiukan.com 123  bbb  jpg

  1. #!/bin/sh 
  2. squidcache_path="/squidcache" 
  3. squidclient_path="/home/local/squid/bin/squidclient" 
  4. #grep -a -r $1 $squidcache_path/* | grep "http:" | awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' > cache.txt 
  5. if [[ "$1" == "swf" || "$1" == "png" || "$1" == "jpg" || "$1" == "ico" || "$1" == "gif" || "$1" == "css" || "$1" == "js" || "$1" == "html" || "$1" == "shtml" || "$1" == "htm"   ]]; then 
  6. grep -a -r .$1 $squidcache_path/* | strings | grep "http:" | awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' | grep "$1$" | uniq > cache.txt 
  7. else 
  8. grep -a -r $1 $squidcache_path/* | strings | grep "http:" |grep $2$ |grep $3$|grep $4$|grep $5$ |grep $6$| awk -F 'http:' '{print "http:"$2;}' | awk -F\' '{print $1}' | uniq > cache.txt 
  9. fi 
  10. sed -i "s/\";$//g" cache.txt 
  11. cat cache.txt | while read LINE 
  12. do 
  13. $squidclient_path -p 80 -m PURGE $LINE 
  14. done 

 

squid启动文件

  1. cat >> /etc/init.d/squid <<EOF 
  2. #!/bin/bash 
  3. #chkconfig: 345 85 15 
  4. #description: squid test 
  5. #BY liyaoyi 2012-05-04 
  6.   
  7. . /etc/rc.d/init.d/functions 
  8. squid="/usr/local/squid/sbin/squid" 
  9. prog="squid" 
  10. RETVAL=0 
  11. start() { 
  12.         echo -n $"Starting $prog: " 
  13.         daemon $squid -s 
  14.         RETVAL=$? 
  15.         echo 
  16.         return $RETVAL 
  17.         } 
  18. stop () { 
  19.         echo -n $"Stoping $prog: " 
  20.         daemon $squid -k shutdown 
  21.         echo 
  22.         return $RETVAL 
  23.         } 
  24. reload () { 
  25.         echo -n $"Reloading $prog: " 
  26.         daemon $squid -k reconfigure 
  27.         echo 
  28.         return $RETVAL 
  29.         } 
  30.   
  31. case "$1" in 
  32.         start) 
  33.                 start 
  34.                 ;; 
  35.         stop) 
  36.                 stop 
  37.                 ;; 
  38.         reload) 
  39.                 reload 
  40.                 ;; 
  41.         restart) 
  42.                 stop 
  43.                 start 
  44.                 ;; 
  45.         *)  
  46.         echo $"Usage: $0 {start|stop|restart|reload}" 
  47.                 RETVAL=1 
  48. esac 
  49. exit $RETVAL 
  50. EOF 
  51.  
  52. chmod a+x /etc/init.d/squid 
  53. chkconfig --add squid 
  54. chkconfig squid on 
  55. /etc/init.d/squid start 
linux
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* 匿名 发表于 2013/11/1 9:22:49
原文是 http://rfyiamcool.blog.51cto.com/1030776/929634