Helpful Information
 
 
Category: Linux Help
Log files - please help!!!

Hy guys!

I'm about to give up...
First up: I have not a lot knowledge about Linux. The company I work for just rented a web-server. I know how to get those Apache Log files to rotate every 24 hours.

But my boss wants monthly ones, which are named like browser_log_2001-10.log. Now I know that I sorta need to merge the daily ones into one monthly one and delte the old daily ones.

Now, I could have Apache make that, but in the Docs it says you shouldn't because of performance.

How would I do this? I searched for progs which would do this task for me, but the only one I could find doesn't work on our Server.

Can anybody point me to a prog like that, or tell me how to do this?

Bear in mind, that I am a total Linux newbie!

Thanks in advance!
Sheriff

I too went throught the same thing with my boss, but I found a program that you should really check out it will take care of you log problems its called webalizer and you can get it from http://www.mrunix.net/webalizer/

Hy-
thanks for your reply, but my problem is the rotation of the logfiles, not the processing. To get our stats, we use something different. But thanks anyways!
best regards
Sheriff

You need a log processing program more than a log rotation one since they are already rotated. The biggest concern is performance and resources, including the merging and parsing whenever your boss needs to read it.

When you can't find such script for such abnormal task, why not writing your own script? It should be plain simple and doesn't take you 1 month of Perl/PHP knowledge.

Once you decide which language to use, and if you have a problem, post it to Perl/PHP forum.

Keep in mind, you don't need to merge them to one big file for parsing. You can even gunzip it on the fly if it's browser_log_2001-10_log.gz.

Actually I was thinking of writing my own PHP script to do what I want it to do.
I have only 2 problems with that:
1) How do I get the Logfile to be read/writeable by PHP?
2) Can I run PHP as a bash script? Cos if I can't I have the problem, that apache will have to do it again...

Oh, at the moment my logfiles are
user/goup: root/root
permissions: -rw-r--r--

If I do it with PHP they need to be r/w for the apache server right?

best regards
Sheriff

In order for any script to proccess the logs, or any file for that matter, its process must have r/w privs.

As for the script itself, I'd actually reccomend using a shell scripting language such as Bourne (Again) or Korn. The script will be a bit simpler (IMO) and run with less overheard. Its also much eaiser to cron a shell script than to do the equivelant to a PHP script.

And, no, as far as I know, you can't run PHP as a bash script.

>> 1) How do I get the Logfile to be read/writeable by PHP?

The user Apache runs as just need priviledge to READ, not WRITE. And permissions: -rw-r--r-- is world-readable and fine.

>> 2) Can I run PHP as a bash script?

If you can't use PHP to do it, always look for alternative. BTW, you can write a Perl or Shell script or whatever to do the backend stuff via cron and use PHP as the frontend for viewing log info via browser.

If you don't know where to start, go buy a Perl for dummies or PHP newbie book. The task you need to do is very basic.

I would havethought Perl would be the obvious choice here, being more suited for admin scripting... in fact you'll probably find there are loads of Perl scripts hidden throughout your OS already. And if you like you can give the script a web frontend too. Look for O'Reilly - Learning Perl, or O'Reilly - Programming Perl (or both, even better!).










privacy (GDPR)