Welcome to WebmasterWorld Guest from 107.22.14.254

Forum Moderators: bakedjake

Message Too Old, No Replies

Split apache2 logfiles

     
3:05 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A linux server running Apache 2.0.54

I have a server with many sites configured using Mass Virtual Hosting [httpd.apache.org] and apache2 is set to log to one single file (for all hosts) each day using the 'Combined' format (i.e. with the hostname at the start of each log entry), the file is called vhost.YYMMDD and is autogenerated each day.

Before processing, I need to split these logfiles using Apache's split-logfile [httpd.apache.org] command, is there an easy way to run this on every file in a folder?

BTW, running split-logfile < /var/log/apache2/vhost.* doesn't work - I've already tried :-(

4:45 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You could write another script (or modify the script provided) to loop through any given directory. Or, another option might be to find and exec, something along the lines of ...

find /var/log/apache2/vhost.* -exec split-logfile

Double check that syntax, at least you get an idea though.

You may want to ask this question in the *nix forum. There are some bright admins that hang out there that may have a better solution.

5:14 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



find /var/log/apache2/vhost.* -exec split-logfile

thanks for the tip, I'll give it a try.

You may want to ask this question in the *nix forum

To save duplicate posting, might a friendly moderator move this thread over there [webmasterworld.com], please?

5:38 pm on Dec 18, 2006 (gmt 0)



See... I am awake :) what... where am I... What's a *nix :)
9:26 pm on Dec 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



find /var/log/apache2/vhost.* -print ¦ xargs cat ¦ split-logfile should work. If there are a lot of files, you might want to cd to /var/log/apache2 first to cut down on the file name lengths.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month