Solved

access_log roll over weekly

Posted on 2004-09-28
9
779 Views
Last Modified: 2008-02-26
Hi!

I wonder what strategies there are for monitoring the Apache access_log and to automitically roll over each week.

What is the easiest way if I don't want to install any software, and what is the easiest way if I can install log monitoring tools?

Any help is greatly appreciated!

Thanks in advance!

best regards,

Tom-Erik
0
Comment
Question by:tomerikv
  • 4
  • 3
  • 2
9 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 150 total points
ID: 12167432
No install. write a little cron script, something like:
#!/bin/ksh
DATE=`date +%d-%b-%y`
mv /usr/local/apache/logs/error_log /usr/local/apache/logs/archive/error_log.$DATE
mv /usr/local/apache/logs/access_log /usr/local/apache/logs/archive/access_log.$DATE
touch /usr/local/apache/logs/error_log
touch /usr/local/apache/logs/access_log
/usr/local/apache/bin/apachectl graceful
gzip /usr/local/apache/logs/archive/error_log.$DATE
gzip /usr/local/apache/logs/archive/access_log.$DATE

For external software look at cronolog http://cronolog.org/
0
 
LVL 1

Author Comment

by:tomerikv
ID: 12167484
Hi again,

Thanks a lot!

I also wonder, if I am to use it on Windows too, are there any chance to do a similar thing on Windows 2000 as well?

best regards,

Tom-Erik
0
 
LVL 18

Expert Comment

by:liddler
ID: 12167507
...probably, using logrotate and maybe schedular.
 have a look at http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20784813.html
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 15

Assisted Solution

by:periwinkle
periwinkle earned 50 total points
ID: 12169959
Isn't logrotate a Linux/Unix utility?  That would be my recommendation for that platform (especially as you need to restart the web server after rotating the log;  you can easily do so with a post-log rotation command using logrotate).

Perhaps you are thinking of rotatelogs.

Cronolog apparently has a Win32 version as well as a Linux/Unix version - you'll probably be able to do something there with the scheduler.
0
 
LVL 1

Author Comment

by:tomerikv
ID: 12171697
Hi again,

I have now tried rotatelogs

I commented out and added this line to httpd.conf:

# CustomLog logs/access_log common

CustomLog "|C:/Ora_app/Apache/Apache/bin/rotatelogs.exe C:/Ora_app/Apache/Apache/logs/access_log 86400" common

After I made that change Apache won't start.

The HTTP SERVER.1 gave this error:
[Tue Sep 28 19:06:15 2004] [error] (9)Bad file descriptor: dup2(stdin) failed
ap_spawn_child: Bad file descriptor
Couldn't fork child for piped log process

I also tried to move rotatelogs like suggested in:

http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20784813.html

This did not work either.

Any ideas what is wrong?

best regards,

Tom-Erik


0
 
LVL 15

Expert Comment

by:periwinkle
ID: 12172070
As I understand it, the unable to fork usually is the result of having insufficient permissions to be able to.  Is it possible that the permissions aren't set up properly for the rotatelogs command?
0
 
LVL 15

Expert Comment

by:periwinkle
ID: 12172116
This question/answer seems to be extremely relevent:

http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20784813.html

possibly, you'll have to move the location of your logs?  AAR, you'll need to make certain that the user that Apache runs under has permission to execute the rotatelogs.exe command, and can create and write to files in the directory where the logs are located.
0
 
LVL 1

Author Comment

by:tomerikv
ID: 12174938
Hi,

I also tried this, but I got the same error.

I didn't try to just move the default logging directory without doing any other changes , so I will try this and then update the result when I know if that works.

regards Tom-Erik
0
 
LVL 1

Author Comment

by:tomerikv
ID: 12363576
Hi!

Sorry for the late answer. It did work with rotatelogs, but I had to add a tag in the Oracle opmn.xml file. The error is related to Apache and Win2000:

The fix was:
Steps to correct:
1. Edit $ORACLE_HOME\opmn\conf\opmn.xml
2. Change line:
<ohs gid="HTTP Server"/>
to:
<ohs gid="HTTP Server">
<environment>
<prop name="ComSpec" value="C:\WINNT\system32\cmd.exe"/>
</environment>
</ohs>
3. Restart ProcessManager service and it will work.


Thanks for your help!

best regards,

Tom-Erik




0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Curl Multi-exec 13 72
Apache server crashes randomly 38 120
Guacamole and browser performance 1 106
Increase size of permitted URI 4 54
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 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