Solved

access_log roll over weekly

Posted on 2004-09-28
9
769 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
Comment Utility
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
Comment Utility
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
Comment Utility
...probably, using logrotate and maybe schedular.
 have a look at http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20784813.html
0
 
LVL 15

Assisted Solution

by:periwinkle
periwinkle earned 50 total points
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Author Comment

by:tomerikv
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now