Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-02-26
8
Medium Priority
?
448 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
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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

581 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