Re: Are You Able To help?

From: Oskar Pearson <>
Date: Fri, 31 Jan 1997 09:11:54 +0200 (GMT)


> I like the idea of the Squid Users documentation. I have a particular
> problem at the moment. MAybe you can tell me if it is sufficiently Squid
> related to include, and if you know the solution to my query, I would be
> extremelly grateful if you could let me know.

After playing around with the squid "RunCache" script, I decided that I
thought it was too inefficient... I wrote a perl script that should
do the trick. We have created a user "squid" and a group "squid" on
the machine, and have changed squid.conf to say
cache_effective_user squid squid
pid_filename /tmp/

(You need perl for the script to run)

whens squid installs itself (if you type "make install" as root)
it makes the directory /usr/local/squid

Make sure that all of the files in that directory are owned by squid,
otherwise it can't write to the log files.

Then put the following line in the user squid's crontab
1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * /usr/local/bin/runcache

And make sure of the following:

There is no script that goes and cleans out files older that a few days
in /tmp (otherwise your pid file will get deleted)

then edit /usr/local/bin/runcache:

#!/usr/bin/perl -w
# Oskar Pearson - Restarts the proxy, mails logs to us if there is a
# problem with it...

$SIG{'ABRT'} = 'handler';

if(-e "/tmp/dont.restart.squid"){

if(-e "/tmp/"){

while (1) {
        $starttime = `/bin/date`;
        chop $starttime;
        open(RUNNING,"/usr/local/squid/bin/squid -D|");
        @log = <RUNNING>;
        @log = "";
        $dietime = `/bin/date`;
        chop $dietime;
        open(SENDMAIL,"|/usr/lib/sendmail -fnobody\ services\");
print SENDMAIL "The cache died at $dietime, after starting at\n";
        print SENDMAIL "$starttime\n";
        print SENDMAIL "A tail of the logs follows:\n\n";
        open(TAIL,"/usr/bin/tail -200 /usr/local/squid/logs/cache.log|");
        while (<TAIL>) {print SENDMAIL "$_";}
        $pid = `cat /tmp/`;
        system("kill $pid");
        `rm /usr/local/squid/cache/squid.core`;

sub handler {
        print KILLED "Killed with -ABRT\n";
        `/usr/sbin/chown squid.squid /tmp/dont.restart.squid`;


> I even thought of adding a line to local.rc, but we don't have one. All
> I want to do is make it run at boot time. Any suggestions?

This script should never really die (hasn't once on our systems - up for
numerous months) so if you put the script in an rc.local file you
don't need to put it in cron, but it will function perfectly in cron.


'experience made art, but inexperience luck.'
Received on Thu Jan 30 1997 - 23:22:05 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:34:13 MST