Showing posts with label clear Squid Cache. Show all posts
Showing posts with label clear Squid Cache. Show all posts

Shell script clear Squid Cache on pfSense

Friday, October 19, 2012

จากการที่ใช้ pfSene ทำเป็น firewall , proxy server นั้น นานนับปีแล้ว อย่างที่เคยบอกไป pfSense มันเสถียรพอได้ จนถึงตอนนี้ยังไม่พบปัญหากวนใจเลย ที่ต้องตรวจเช็คอยู่บ่อยๆ ก็คือ หน่วยจำ cache ของ pfSense ครับ วันนี้มาแนะนำการสร้าง shell script เพื่อลบ cache กันครับ

1. เชื่อมต่อไปยังเครื่องที่ติดตั้ง pfSense โดยเปิด terminal ขึ้นมาแล้วใช้คำสั่ง
ssh -l root ippfSense
ตัวอย่างของผมเป็น
ssh -l root 192.89.0.254
ใส่พาสเวิร์ดให้ถูกต้อง แล้วกด 8 -> กด Enter ดังรูป
2. ทำการสร้าง shell  โดยตั้งชื่อเป็น squid.sh (หรือชื่ออะไรก็ได้ แต่ต้องมีนามสกุล .sh)
vi /var/squid/squid.sh 
แล้วพิมพ์โค้ดด้านล่างลงไป
 /usr/local/etc/rc.d/squid.sh stop
 rm -rf /var/squid/cache/
 mkdir -p /var/squid/cache/
 chown squid:squid /var/squid/cache/
 chmod 777 /var/squid/cache/
 squid -z
 /usr/local/etc/rc.d/squid.sh start
จากนั้น save โดยกด :wp
3. กำหนดสิทธิ์ให้กับ squid.sh
chmod 777  /var/squid/squid.sh
4. สั่งให้ script ทำงาน เพื่อเคลียร์ cache กันครับ ใช้คำสั่ง
/var/squid/squid.sh
note : ตำแหน่งพาธ /var/squid/cache/  แต่ละเครื่องอาจจะไม่เหมือนกันน่ะครับ รูปด้านล่างเป็นตัวอย่าง ของผม

 
 

Pfsense Thailand Copyright © 2011-2012 | Powered by Blogger