LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-18-2003, 05:23 AM   #1
teeno
Member
 
Registered: Jul 2001
Posts: 72

Rep: Reputation: 15
Apache logrotate


Hi All,

I have added the following lines to my logrotate file to remove entries that include cmd.exe.

grep /var/log/httpd/access_log -ve "cmd.exe" > /var/tmp/httpd/access_log
mv -f /var/tmp/httpd/access_log /var/log/httpd/access_log

The problem is that Apache stops logging after these commands have been executed. Why and how do I fix the problem? At the moment I am having to restart Apache.

Thank you
 
Old 07-18-2003, 05:43 AM   #2
MasterC
Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
Funny you should mention that, I JUST finished touching up this log entry

As your postrotate bit, have it restart apache:
postrotate
/sbin/apachectl restart
endscript
Where /sbin/apachectl is the actual location for your apachectl file

If you don't mind me askin, where did you find that above sequence?

And where are you implementing it, as prerotate?

Cool
 
Old 07-18-2003, 06:22 AM   #3
teeno
Member
 
Registered: Jul 2001
Posts: 72

Original Poster
Rep: Reputation: 15
At the moment I have this line after postrotate:

/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true

What is this line doing? Should I restart apache after this line?

Can I use "/etc/rc.d/init.d/httpd restart" to restart apache?


Someone posted those two lines on this site a long time ago.

I have included them at the top of /etc/cron.daily/logrotate

Cheers
 
Old 07-18-2003, 08:13 AM   #4
MasterC
Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu
Posts: 12,612

Rep: Reputation: 64
Whoa! Ok, let's work this out a bit...

/etc/cron.dail/logrotate should be left alone. You should be creating scripts in /etc/logrotate.d/ OR editing the /etc/logrotate.conf directory. Either way, you should be using the same syntax I prefer the /etc/logrorate.d because I can safely not touch my conf file and remove/add logs to be rotated without comprimising the others.

Anyway, so onto more good stuff...

/bin/kill ....
That's taking what is possibly your pid of httpd IF you have that directive in your apache/httpd.conf file. However, it's easier to use what you suggested:
/etc/rc.d/init.d/httpd restart
The line:
/bin/kill ...
Is something you might look further into though, just to learn what's going on there. However, it's really OVERKILL and you should have no problem using an easier command to restart apache (the one you suggested).

HTH

COol
 
Old 08-06-2003, 10:51 PM   #5
Donboy
Member
 
Registered: Aug 2003
Location: Little Rock, Arkansas
Distribution: RH, Fedora, Suse, AIX
Posts: 736

Rep: Reputation: 31
Could I also use: "service httpd restart"?

Would that do the same thing? Or am I required to use a full path for this like teeno suggested?

Also, what file are you editing under rotate.d? I'm running RH9 and I just looked there and I see a bunch of files, one of which is "httpd".

Opening this file, I find the following contents:

/var/log/httpd/*log {
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}

So let me see if I understand this...

I should go into /etc/cron.daily/logrotate and add the following line...

/usr/sbin/logrotate /etc/logrotate.d/httpd

Do I have that right? As I understand it, that means it will run logrotate (daily) using the httpd config file you said to edit?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache crash on cron->logrotate (weekly) pezzer55 Linux - Software 7 09-30-2008 07:58 PM
LogRotate Webmin - Apache Crashes brooky Linux - Software 0 04-26-2004 02:16 AM
Logrotate Help! MaverickApollo Linux - Software 3 02-19-2004 12:09 PM
logrotate dominant Linux - Newbie 1 02-13-2004 09:28 AM
logrotate MrJoshua Linux - General 2 09-25-2002 09:55 AM


All times are GMT -5. The time now is 05:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration