logrotate macht nix

Apache, Lighttpd, nginx, Cherokee
Post Reply
mikum
Posts: 4
Joined: 2006-06-27 11:57
 

logrotate macht nix

Post by mikum »

Hallo Experten!

meine access_logs sollen per logrotate versioniert werden. Ich möchte aber keine gezippten Dateien sondern einfach eine Versionsnummer hinten dran.
Jetzt hatte ich mir so gedacht, dass es mit folgender Konfiguration gehen müsste:

/etc/logrotate.d/apache2:

Code: Select all

/var/log/apache2/access_log {
    rotate 4
    notifempty
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}
/etc/logrotate.conf:

Code: Select all

rotate 4
create
include /etc/logrotate.d
Wenn ich dann zu Test-Zwecken
/usr/sbin/logrotate -dfv /etc/logrotate.conf
aufrufe, scheint logrotate auch was zu machen:

Code: Select all

rotating pattern: /var/log/apache2/access_log  forced from command line (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/access_log
  log needs rotating
rotating log /var/log/apache2/access_log, log->rotateCount is 4
renaming /var/log/apache2/access_log.4 to /var/log/apache2/access_log.5 (rotatecount 4, logstart 1, i 4),
renaming /var/log/apache2/access_log.3 to /var/log/apache2/access_log.4 (rotatecount 4, logstart 1, i 3),
renaming /var/log/apache2/access_log.2 to /var/log/apache2/access_log.3 (rotatecount 4, logstart 1, i 2),
renaming /var/log/apache2/access_log.1 to /var/log/apache2/access_log.2 (rotatecount 4, logstart 1, i 1),
renaming /var/log/apache2/access_log.0 to /var/log/apache2/access_log.1 (rotatecount 4, logstart 1, i 0),
renaming /var/log/apache2/access_log to /var/log/apache2/access_log.1
creating new log mode = 0644 uid = 0 gid = 0
running postrotate script
running script with arg /var/log/apache2/access_log: "
     /etc/init.d/apache2 reload
"
removing old log /var/log/apache2/access_log.5
Am Ende wurde aber keine einzige Datei ins Verzeichnis /var/log/apache2/ geschrieben.

Hat jemand eine Idee, was ich falsch mache?

Gruß,
mikum
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: logrotate macht nix

Post by Joe User »

Code: Select all

ls -alh /var/log/apache2
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
mikum
Posts: 4
Joined: 2006-06-27 11:57
 

Re: logrotate macht nix

Post by mikum »

Joe User wrote:

Code: Select all

ls -alh /var/log/apache2
Leider ist es nicht so einfach. Auch der ls -alh zeigt nix weiter an, außer halt das eine access_log.

:cry:
User avatar
Joe User
Project Manager
Project Manager
Posts: 11191
Joined: 2003-02-27 01:00
Location: Hamburg
Contact:
 

Re: logrotate macht nix

Post by Joe User »

Code: Select all

empty log files are not rotated
PayPal.Me/JoeUserFreeBSD Remote Installation
Wings for LifeWings for Life World Run

„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
mikum
Posts: 4
Joined: 2006-06-27 11:57
 

Re: logrotate macht nix

Post by mikum »

Joe User wrote:

Code: Select all

empty log files are not rotated
# ls -alh /var/log/apache2/acc*
-rw-r--r-- 1 root root 17M Jun 27 14:12 /var/log/apache2/access_log
mikum
Posts: 4
Joined: 2006-06-27 11:57
 

Re: logrotate macht nix

Post by mikum »

Okay, ich habe zumindest schonmal rausgefunden, warum beim Befehl
/usr/sbin/logrotate -dfv /etc/logrotate.conf
nicht wirklich was passiert:

Code: Select all

logrotate -d file

This will show you what it will do, without actually rotating anything, and this is most valuable while testing complex setups that you don’t want to ‘play’ with the logs to see if your configuration will work as you want it.
:roll:
Post Reply