how do I reduce the size of the \var\log\httpd\combined_log file


I am running Caldera OpenLinux eServer 2.3.  The \var\log\httpd\combined_log file is at 370 MB and growing.
What is the best way to shrink this file and get it to stay at a managable size, maybe a meg or so.
jstelpflugAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nick AccadSystems AdministratorCommented:
logrotate

if you have logrotate running on your system, you can just
add a cron job

create a file /etc/rotate_httpd_log

#create a new log everyday
daily
#keep 7 days worth of old files
rotate
#compress the old files to save space
/var/log/httpd/combined_log {
  postrotate
    killall -HUP httpd
  endscript
}

now create a cron job to run this every night, something like
59 11 * * * logrotate /etc/rotate_httpd_log

if you dont have logorotate, ftp it from somewhere, but
im sure caldera already has it.

good luck
-nick
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
achrid9Commented:
or if you don't have logrotate running on your system, you could cron a simple shell script like this one to take care of everything before the last X number of lines.

-----------
#!/bin/bash

file_path="/etc/rotate_httpd_log"

tail -250 $file_path | cat > $file_path
-----------

And you are all set. Set this in cron daily and it would blow away everything but the most recent 250 lines of that log file.

NOTE: At a glance people say "why are you piping it through cat when you could just do a 'tail file1 > file1'" The answer is because if you were just doing a redirect, it would do everything at the same time and since you are overwriting the file that you are reading from... you just end up with an empty file. Piping it through cat is a simple way to load what you want into memory before performing the overwrite. (I am a UNIX weenie ;-])
0
heskyttbergCommented:
Hi!

achrid9 clever, I done that misstake some times, never thought of the idea to pipe it through cat, ending up with an empty file isn't always funny.

Good tip, :)

Regards
/Hans - Erik Skyttberg
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jimbbCommented:
Another option for log rotation would be to use the "rotatelogs" command which comes with apache.  In your httpd.conf you pipe the log output to it, and rotatelogs writes the logs to variable filenames.  Then you can run (weekly, daily, whatever) a cron job which cleans out the old ones.

I prefer this method because a) you get to keep all the old logs, for as long a period as you determine) and b) you don't need to -HUP the httpd (which breaks any open connections).

On the down side, it will create 2 extra processes per virtual host, as well as use a tiny amount of extra memory.  But it's not much.

Example:
CustomLog "| rotatelogs /var/log/virtual/www.domain.com/access_log_%Y-%m-%d 86400 -300" combined

This would create the log file as access_log_(date) therefore leaving you with a new log file every day.  No need to restart the server.
0
knowsthCommented:
You could also use cronolog which is a program to filter logs and save them to appropriate files.  The most common implementation is to save a daily log, with a filename containing the respective date and whether it's an access or error log.
Take a look at cronolog.org (I am in no way associated with them, but use it in the office!).
0
jimbbCommented:
cronolog I think does the same thing as rotatelogs.  In fact before I found out about rotatelogs, I saw cronolog mentioned in a mailing list archive and looked into it; at that point I found that the functionality I wanted had been incorporated into rotatelogs so I ended up using that.
0
CleanupPingCommented:
jstelpflug:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
paullamhkgCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is to:

Accept naccad's Comments as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Paul
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.