?
Solved

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

Posted on 2003-02-26
8
Medium Priority
?
443 Views
Last Modified: 2007-12-19

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.
0
Comment
Question by:jstelpflug
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Accepted Solution

by:
naccad earned 100 total points
ID: 8028376
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
 

Expert Comment

by:achrid9
ID: 8028677
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
 
LVL 8

Expert Comment

by:heskyttberg
ID: 8029340
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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 2

Expert Comment

by:jimbb
ID: 8035516
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
 

Expert Comment

by:knowsth
ID: 8109477
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
 
LVL 2

Expert Comment

by:jimbb
ID: 8111190
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
 

Expert Comment

by:CleanupPing
ID: 9087848
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
 
LVL 12

Expert Comment

by:paullamhkg
ID: 9260332
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

Featured Post

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question