LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   deleting squid access logs (https://www.linuxquestions.org/questions/linux-server-73/deleting-squid-access-logs-852014/)

aliabbass 12-23-2010 09:13 AM

deleting squid access logs
 
Is there any way to delete squid proxy access logs if someone knows then please share how can the access logs be deleted

bathory 12-23-2010 04:42 PM

Try:
Code:

rm /var/log/squid/access.log
If access.log is located somewhere else check squid.conf to find its actual location.
After deleting the logfile don't forget to reload squid

Regards

kaushalpatel1982 12-23-2010 11:31 PM

echo > /var/log/squid/access.log

getviswa 12-24-2010 12:53 AM

You can use "sbin/squid -k rotate" ... it will rotate access.log to access.log.0 and access.log will be fresh.

aliabbass 12-24-2010 12:57 AM

Quote:

Originally Posted by bathory (Post 4201539)
Try:
Code:

rm /var/log/squid/access.log
If access.log is located somewhere else check squid.conf to find its actual location.
After deleting the logfile don't forget to reload squid

Regards

well i am sorry i did n't explain the whole scenario
what i want is to delete logs of particular ip i mean system that is using squid as a proxy and i want to delete the access logs of that particular system on particular date like Dec 23
i hope that every body will now understand the problem

getviswa 12-24-2010 03:02 AM

You can use this script
#1- pass the argument like "Jan 1 172.16.1.45"
#2- it will create temp.log -- u just delete access.log and rename temp.log to access.log


#! /usr/bin/perl
open INPUTFILE, "<", "access.log" or die $!;
open OUTPUTFILE, ">", "temp.log" or die $!;
$m_=$ARGV[0];
$d_=$ARGV[1];
$ip_=$ARGV[2];
while (<INPUTFILE>) {

@textline=split(" ",$_);


#print "@textline[0] @textline[2] \n";
@time=split(" ",localtime(@testline[0]));
if((@time[1] eq $m_ ) && (@time[2] eq $d_) && (@textline[2] eq $ARGV[2]))
{
$flag=1;
}
if($flag==0)
{
print OUTPUTFILE $_;
}
$flag=0;

}



Thank
-Viswa

aliabbass 12-29-2010 11:01 PM

Quote:

Originally Posted by getviswa (Post 4201881)
You can use this script
#1- pass the argument like "Jan 1 172.16.1.45"
#2- it will create temp.log -- u just delete access.log and rename temp.log to access.log


#! /usr/bin/perl
open INPUTFILE, "<", "access.log" or die $!;
open OUTPUTFILE, ">", "temp.log" or die $!;
$m_=$ARGV[0];
$d_=$ARGV[1];
$ip_=$ARGV[2];
while (<INPUTFILE>) {

@textline=split(" ",$_);


#print "@textline[0] @textline[2] \n";
@time=split(" ",localtime(@testline[0]));
if((@time[1] eq $m_ ) && (@time[2] eq $d_) && (@textline[2] eq $ARGV[2]))
{
$flag=1;
}
if($flag==0)
{
print OUTPUTFILE $_;
}
$flag=0;

}





Thank
-Viswa

thanks viswa for providing this useful script


All times are GMT -5. The time now is 01:52 AM.