Página 1 de 1

Delete/Refresh Cache files and Logs files, of Sarg and Squid

MensagemEnviado: Ter Nov 25, 2008 3:32 pm
por Lelouch
Delete/Refresh files from Cache/Logs/Sarg of Squid
by EugenioNava Mon 24 Nov, 2008 13:57 pm
(Translated by rinrinrinrenacuajo)

I would like to greetings to everybody from venezuela.

After of my holiday, I am back to BrazilFW.

I am grateful to my friend Marcos do Vale for the responses to my concerns about Squid.

I will attach three (3) Scripts, very useful to use Squid Oficial in any version, and it work at same time with the Sarg as report manager, with the objective of automatize and hold a low cost in our hard disk.

The following list, show the paths and files with hight growing in our BFW server with the squid:

1.) /partition/squid/cache
2.) /partition/squid/logs
3.) /partition/web2/sarg


Scripts:

1.) Delete Cache

#!/bin/sh
#delete cache
# Ing. Eugenio Nava M.
# Version 0.1
# In a Terminal or you can too add it to the cron.

squid -k interrupt

echo "Reconstructing the Oficial Squid Cache...."

sleep 5

rm -Rf /partition/squid/cache/*

sync
sync
sync

#BFW 2.30.1 y BFW 2.31.10
sh /etc/rc.d/pkgs/rc.squid

backup squid

2.) Delete logs

#!/bin/sh
#delete logs
# Ing. Eugenio Nava M.
# Version 0.1
# In a Terminal or you can too add it to the cron.

cd /partition/squid/logs

squid -k rotate

rm -f /partition/squid/logs/*.0
rm -f /partition/squid/logs/*.1
rm -f /partition/squid/logs/*.2
rm -f /partition/squid/logs/*.3
rm -f /partition/squid/logs/*.4
rm -f /partition/squid/logs/*.5
rm -f /partition/squid/logs/*.6
rm -f /partition/squid/logs/*.7
rm -f /partition/squid/logs/*.8
rm -f /partition/squid/logs/*.9

3.) Delete sarg

#!/bin/sh
#Delete sarg
# Ing. Eugenio Nava M.
# Version 0.1
# In a Terminal or you can too add it to the cron.

echo "Reconstructing Oficial Sarg..."

cp /partition/web2/sarg/.htpasswd /partition/squid

rm -Rf /partition/web2/sarg/*

sync
sync
sync

cp /partition/squid/.htpasswd /partition/web2/sarg/

sarg

#BFW 2.30.1 y BFW 2.31.10
sh /etc/rc.d/pkgs/rc.squid

backup squid

Notes:

1.) These scripts can be converted into individual files to be included in the CRON, change the run frequency according to their needs.
2.) These Script let optimize the Hard disk cost in our BFW Server.
3.) These Script let delete and reconstruct the Oficial Squid Cache without interrupt the activities of BFW Server.

I'm waiting for comments.

Eugenio Nava