LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2010, 01:53 PM   #1
tnsnabeel
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Rep: Reputation: 0
Unhappy How to automatically delete squid cashe


Hi All,

I'm using squid as a proxy in our organization. My problem is whenever the squid cash folder size exceeds 3 GB our proxy server starts to hang. Is there a way to write a script that it will automatically delete the squid cash when it exceeds the 3GB limit.

Thanks,
Nabeel
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 10-24-2010, 02:19 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello and Welcome to LinuxQuestions,

Basically what you can do at the command line can be put into a script, so the answer to your question is YES

You'll need to write a script to first check if the limit of 3 Gb is reached (command du), next stop the Squid service, delete the cache, recreate the cache (squid -z) and last start the Squid service again. You can run the script at certain time intervals using cron for example.

Now, if you're going to ask how to write that script then let me point you to some good reading:
Bash for beginners
Advanced Bash Scripting Guide

LQ users are very good in helping out when you put in some work and encounter problems. We're not that eager to do the work for you or offer you ready made solutions

Kind regards,

Eric
 
Old 10-24-2010, 06:09 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Ummm ... that (flushing/deleting the directories) seems like a
pretty hand over fist approach to me. Why on earth wouldn't you
just use squid's cache_dir directive to limit the size it
uses? That's what it's there for.



E.g.:
Code:
cache_dir yadda yadda 2500 16 256

This limits the size to 2.5GB



Cheers,
Tink
Cheers,
Tink
 
2 members found this post helpful.
Old 10-25-2010, 12:23 AM   #4
tnsnabeel
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Thumbs up Thanks

Thanks EricTRA & Tinkster for your prompt reply, I'll try these and get back,

Thanks a lot
Cheers !!!!
 
Old 10-25-2010, 07:23 AM   #5
tnsnabeel
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Question

Hi Tinkster,

It may sound like stupid coz I'm a very very newbie to linux,
I'm a bit confuse about your reply, actually what happens when limiting the size it users. Does it automatically delete the cash when it exceed the limit.

Thanks.
 
Old 10-25-2010, 07:29 AM   #6
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
Quote:
Originally Posted by tnsnabeel View Post
Hi Tinkster,

It may sound like stupid coz I'm a very very newbie to linux,
I'm a bit confuse about your reply, actually what happens when limiting the size it users. Does it automatically delete the cash when it exceed the limit.

Thanks.
I'd expect it to delete the oldest/largest items - but it wont just delete the "whole" cache, it'll just make sure it doesn't exceed that size.
 
Old 11-04-2010, 11:42 PM   #7
tnsnabeel
LQ Newbie
 
Registered: Jul 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Hi Tinkster,

Thanks a lot for your reply, I used this option and its working perfectly. Now I don't have to worry about our proxy getting hang. Thanks a lot.

Nabeel
 
Old 11-05-2010, 12:22 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Most welcome. I'll mark your thread as resolved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I automatically delete old emails in Postfix rcrosoer Linux - Server 7 07-10-2009 03:40 AM
sqlite cashe needs updating tied2 Fedora 1 06-28-2007 05:17 PM
Automatically delete old files depam Linux - Software 1 01-25-2006 08:15 PM
history, tmp and cashe mdk Linux - Newbie 2 08-22-2004 01:12 AM
Editior automatically delete content between lines dnla Linux - Newbie 2 10-21-2003 05:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration