LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-13-2010, 08:30 AM   #1
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Rep: Reputation: 16
Rotating logs in squid 2.7 stable9


Dear Experts,

Hi to all.

I've installed squid 2.7 stable9 in centos 5.4 x32 bit. I've installed and configured it successfully, its working fine. I want to clear few doubts, for that your kind help is needed.

Parallely, I've configured another server using binary rpms with same squid version (2.7 stable9).
I found that it creates a /etc/logrotate.d/squid for rotating log files (access.log, cache.log, store.log). Which is properly rotating log files using compress, dateext and size options (i manually added the size option).

But after compiling and installing from source code, its automatically not created. I want to rotate the log files in the same way as it is doing when i install using binary rpms.

Below logfile_rotate entry is present in my squid.conf file (in source code installation scenario)
logfile_rotate 10

Below logfile_rotate entry is present in my squid.conf file which is commented (in binary rpm installation scenario)
#logfile_rotate 10

I want to rotate the log files by size (as I've more than 200 users, these logfiles size increasing very fast, ie. approx 80 MB per hour), with compress and dateext option.

Is there any change need to be made in squid.conf or logrotate.conf or syslog.conf files ?

Pls suggest.

Rgds
Arunabh
 
Old 08-14-2010, 02:04 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
logrotate has 'size', 'minsize' option to rotate log file by size. Reading through the manual page and add it to /etc/logrotate.d/squid, Ex:

Code:
/var/log/squid/access.log {
    size 500M
    rotate 5
    copytruncate
    compress
    notifempty
    missingok
}
 
Old 08-16-2010, 12:19 AM   #3
arunabh_biswas
Member
 
Registered: Jun 2006
Posts: 92

Original Poster
Rep: Reputation: 16
Thanks Quanta,

For your reply. I knew the options you suggested. I know that these lines should be put in the "squid" file resides in /etc/logrotate.d directory but my concern is something different.

1) While compiling squid through source code, this file is not creating automatically. Whether I need to create it manually and what ownership & permissions should be set on it ?

2) Is this is the only change i have to made or need to edit some more files (i.e. squid.conf, logrotate.conf, syslog.conf)?

3) whether i need to put any entry in cron for rotating squid logs automatically in hourly or daily intervals ?

4) If the log files size is average 80 MB approx in an hour, what should be the interval i should set to rotate it 10 MB per file ?

Eagarly waiting for you replies guys.

Thanks
Arunabh

Last edited by arunabh_biswas; 08-16-2010 at 12:20 AM.
 
Old 08-16-2010, 02:18 AM   #4
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by arunabh_biswas View Post
For your reply. I knew the options you suggested. I know that these lines should be put in the "squid" file resides in /etc/logrotate.d directory but my concern is something different.

1) While compiling squid through source code, this file is not creating automatically. Whether I need to create it manually and what ownership & permissions should be set on it ?
Yes, working under Linux sometime you must create config file manually if it doesn't exist.

For ownership & permissions you can refer to package installed by binary file, on my system:
Code:
-rw-r--r-- 1 root root 543 Jan 21  2009 /etc/logrotate.d/squid
Quote:
Originally Posted by arunabh_biswas View Post
2) Is this is the only change i have to made or need to edit some more files (i.e. squid.conf, logrotate.conf, syslog.conf)?
You can change more options in squid.conf if you want. Notice that logrotate.conf is global config file and /etc/logrotate.d including config files which for individual service (it will overwrite global options)
Quote:
Originally Posted by arunabh_biswas View Post
3) whether i need to put any entry in cron for rotating squid logs automatically in hourly or daily intervals ?
If you install from binary file you will see logrotate file in /etc/cron.daily (default). Otherwise you can manually create it or put it in /etc/cron.hourly (depend on you) with something like this:
Code:
#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
Quote:
Originally Posted by arunabh_biswas View Post
4) If the log files size is average 80 MB approx in an hour, what should be the interval i should set to rotate it 10 MB per file ?
No need to care for interval if you rotate based on logs file size. (I haven't tested )

Supplement: I have re-read the manpage:
Quote:
minsize size
Log files are rotated when they grow bigger then size bytes, but not before the additionally speci-fied time interval (daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When minsize is used, both the size and timestamp of a log file are considered.

Last edited by quanta; 08-16-2010 at 09:29 AM.
 
  


Reply



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
Rotating Apache logs and Webalizer xMeta4x Linux - Software 5 03-20-2009 12:42 AM
Problem rotating Postfix logs keyF Linux - Software 3 08-30-2006 07:56 AM
Samba logs rotating like crazy josephswagner Linux - Software 1 07-07-2004 09:55 AM
problems rotating logs uros678 Linux - Software 0 12-15-2003 02:55 AM
Squid and rotating logs using crond 80s Linux - Software 0 02-21-2003 03:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:32 PM.

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
Open Source Consulting | Domain Registration