Solved

access_log roll over weekly

Posted on 2004-09-28
9
772 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
 
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

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…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

914 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

17 Experts available now in Live!

Get 1:1 Help Now