From owner-freebsd-questions@FreeBSD.ORG Thu Feb 15 18:24:19 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9EECA16A402 for ; Thu, 15 Feb 2007 18:24:19 +0000 (UTC) (envelope-from david.robillard@gmail.com) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.228]) by mx1.freebsd.org (Postfix) with ESMTP id 5232B13C481 for ; Thu, 15 Feb 2007 18:24:19 +0000 (UTC) (envelope-from david.robillard@gmail.com) Received: by nz-out-0506.google.com with SMTP id i11so688654nzh for ; Thu, 15 Feb 2007 10:24:18 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:mime-version:content-type:content-transfer-encoding:content-disposition; b=Rn3lzFRNkL1bCNjjNSd1mODd04E7YvF98B/w67Uo2tyjAXxYVVE6Y15ziJZqdgpFWXXLxbSW9oc6ibUUy3V9yabbmnlCpbv0uydjACqbgJSnZl4y4Yd5ee61GKcQJUXDUIhut+xm60xO44sTulHHHfRwgLMahQ/wH5MwJcz/Awg= Received: by 10.65.159.2 with SMTP id l2mr3362333qbo.1171563858791; Thu, 15 Feb 2007 10:24:18 -0800 (PST) Received: by 10.65.11.16 with HTTP; Thu, 15 Feb 2007 10:24:18 -0800 (PST) Message-ID: <226ae0c60702151024u6c71d50bn72d54631c33ed32@mail.gmail.com> Date: Thu, 15 Feb 2007 13:24:18 -0500 From: "David Robillard" To: "FreeBSD Questions" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Cc: Peter Pluta Subject: Re: Apache Rotate Logs and Log Rotate. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Feb 2007 18:24:19 -0000 > I have Apache making separate log files for each of my virtual hosts and > putting them in /home/vhostname/log. Rotate logs makes a new log every > 24 hours, but the logs quickly add up and since the sites are fairly > busy the logs are at times over 5gigs. Is there any way to make rotate > logs delete the log files after two days? Someone recommended me Log > Rotate (from the ports tree), but this program does basically what > Rotate logs does; except it makes things more complicated because it > needs to restart apache and such. Is there a easy way to just have > Apache's rotatelogs rotate the logs and then delete them after two days? > > Any feedback, suggestions, or comments would be greatly appreciated. Hi Peter, I personaly don't use neither Log Rotate nor Rotate Logs, but configure newsyslog.conf(5) to handle the job of Apache log rotation and clean-up. The newsyslog software is part of FreeBSD's base system, so you don't need to install anything. Just configure /etc/newsyslog.conf and that's it. No need to restart anything because newsyslog is already active in FreeBSD's base system via /etc/crontab. It can rotate the logs, compress them with either gzip(1) or bzip2(1) and remove the old ones to preserve disk space. For example, let's say you have two virtual host's logs into /home/vhostname1/log and /home/vhostname2/log, you can configure newsyslog to: a) Keep only 10 log files. Remove the older ones as they grow. (i.e. 10 in the config below) b) Create files with chmod 640 and owner root:www (i.e. root:www and 640) c) Rotate the files when they reach 1Mb in size. (i.e. 1048576) d) Compress the files with gzip(1) to preserve compatibility with webalizer. (i.e. Z) # logfilename [owner:group] mode count size when flags [/pid_file] [sig_num] # Host vhostname1. # /home/vhostname1/log/access.log root:www 640 10 1048576 * Z /var/run/httpd.pid /home/vhostname1/log/error.log root:www 640 10 1048576 * Z /var/run/httpd.pid # Host vhostname2. # /home/vhostname2/log/access.log root:www 640 10 1048576 * Z /var/run/httpd.pid /home/vhostname2/log/error.log root:www 640 10 1048576 * Z /var/run/httpd.pid Check the man pages for newsyslog(8) and newsyslog.conf(8) for more information. I've been using this for more then two years now and it works like a charm. HTH, David -- David Robillard UNIX systems administrator & Oracle DBA CISSP, RHCE & Sun Certified Security Administrator Montreal: +1 514 966 0122