Page 1 of 1

logrotate macht nix

Posted: 2006-06-27 12:40
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

Re: logrotate macht nix

Posted: 2006-06-27 12:54
by Joe User

Code: Select all

ls -alh /var/log/apache2

Re: logrotate macht nix

Posted: 2006-06-27 13:02
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:

Re: logrotate macht nix

Posted: 2006-06-27 13:19
by Joe User

Code: Select all

empty log files are not rotated

Re: logrotate macht nix

Posted: 2006-06-27 14:13
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

Re: logrotate macht nix

Posted: 2006-06-28 14:13
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: