How to clean squid cache directory ?

Taking care of your Linux box.
Post Reply
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

How to clean squid cache directory ?

Post by gardenair »

Salam,
I am using squid on my cent os 5. The cache directory is almost full.

# cache_dir ufs /var/spool/squid 2000 16 256
kindly guide me how can i flush or clean the data inside the cache directory of squid.I am using using terminal not Linux GUI interface.

thanks
garden
khizer
Lance Naik
Posts: 20
Joined: Fri Feb 25, 2011 2:40 am
Location: Sharjah

Post by khizer »

First, Check you squid.conf file and locate the location of you cache directory, which in your case is /var/spool/squid

1) Shutdown your squid server
2) Remove the cache directory
3) Re-Create the squid cache directory
4) Start the squid


So in short do the following in the command line as a root user (be very carefull with the second command because one wrong space can wipe your filesystem/harddisk)

1-

Code: Select all

/etc/init.d/squid stop
2-

Code: Select all

rm -rf /var/spool/squid/* 
3-

Code: Select all

squid -z 
4-

Code: Select all

/etc/init.d/squid start 
-Khizer Naeem Mughal

Knowledge is often mistaken for intelligence. This is like mistaking a cup of milk for a cow.
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Post by lambda »

why do you want to delete the contents of your cache directory? the more useful data there is in your cache directory, the more quickly squid can serve users!

squid automatically removes older unused data from the cache directory. you should never need to delete its contents.

if your cache_dir is too large and your filesystem is going to fill up, just lower the size in your squid.conf. i see you have it set to 2000 (which is 2GB). just lower it and then restart squid. squid will delete files to bring it down to the new level.

also, 2GB is nothing -- you should set it to as much space as you can give it. on a 160GB drive, give it 120 or 130GB (leave the rest of the operating system, logs, other stuff).
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

Post by gardenair »

thanks for the reply. Well mostly people say that they frequently delete their cache dir. I also have a ISA server in my another branch and we when the users complaints that they even can not open google web page I just delete the stop my ISA and delete cache of ISA.

As concern to Squid is there any way to check that out of 2 GB how much web pages have been saved in the cache directory ? i.e var/spool/squid.
I have google it but does not find the answer of my question.

Thanks to linuxpakistan forum that here i can discuss my Linux issues .
again thanks a lot for giving time ,
waiting for reply,
garden
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Post by lambda »

i've used squeezer2 in the past, but i don't know if it has what you want.
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
Post Reply