6

I need an alternate for rotating logs on my server, everytime logrotate runs apache goes down for like 10-20 minutes, i'm not sure if this is right, but don't seem right for me.

Is there any alternate for logrotate on apache? That long time to rotate logs is unusual?

My setup is fedora core 9, apache 2.2.14

Thanks.

Rod
  • 371
  • 4
  • 10
  • 4
    10-20 minutes is definitely unusual. The normal practice is to configure logrotate so that when it runs, it signals Apache to do a graceful restart (i.e. reload its configuration and log file handles without actually shutting down). So you should have no downtime at all due to log rotations. – David Z Jul 11 '10 at 23:29

4 Answers4

5

I like cronolog. Apache can pipe the output to cronolog which stores things in logs based on whatever template you use.

On my server where I use these two directives in the global scope only one copy of cronolog started and used for writing logs. This will create a new log file for each year+month.

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedvhost
CustomLog "|/usr/bin/cronolog /var/log/apache2/%Y%m.combined.allhosts.log" combinedvhost
Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • Thanks that's what i was looking for, no need to restart apache in order to rotate logs. – Rod Jul 12 '10 at 03:25
2

I would look into the options passed to logrotate.

In my experience you should use copytruncate (log files are copied first, then truncated).

This also negates the need to restart apache after logrotate has finished.

sastorsl
  • 362
  • 2
  • 15
1

everytime logrotate runs apache goes down for like 10-20 minutes, i'm not sure if this is right, but don't seem right for me

No - sounds like your system is broken - I'd be tempted to fix it rather than trying something else - logrotate is a very useful tool used properly.

What does your current logrotate script(s) look like?

C.

symcbean
  • 21,009
  • 1
  • 31
  • 52
1

If you restart Apache manually, does it also take 10-20 minutes?

If it's taking that long to rotate logs, it seems like Apache is getting stuck somewhere which would happen manually too or logrotate is running into disk issues when trying to move the logs.

Is the compress option on? If it is, what happens when you turn it off?

David
  • 3,487
  • 26
  • 20