Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-23-2010, 10:13 AM
|
#1
|
Member
Registered: Jun 2008
Posts: 57
Rep:
|
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
|
|
|
12-23-2010, 05:42 PM
|
#2
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,220
|
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
|
|
|
12-24-2010, 12:31 AM
|
#3
|
Member
Registered: Aug 2007
Location: INDIA
Distribution: CentOS, RHEL, Fedora, Debian, Ubuntu, LinuxMint, Kali Linux, Raspbian
Posts: 166
Rep:
|
echo > /var/log/squid/access.log
|
|
|
12-24-2010, 01:53 AM
|
#4
|
LQ Newbie
Registered: May 2010
Posts: 23
Rep:
|
You can use "sbin/squid -k rotate" ... it will rotate access.log to access.log.0 and access.log will be fresh.
|
|
|
12-24-2010, 01:57 AM
|
#5
|
Member
Registered: Jun 2008
Posts: 57
Original Poster
Rep:
|
Quote:
Originally Posted by bathory
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
|
|
|
12-24-2010, 04:02 AM
|
#6
|
LQ Newbie
Registered: May 2010
Posts: 23
Rep:
|
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
|
|
|
12-30-2010, 12:01 AM
|
#7
|
Member
Registered: Jun 2008
Posts: 57
Original Poster
Rep:
|
Quote:
Originally Posted by getviswa
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:57 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|