• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[gelöst] Logrotate Apache Log hängt

peavey

Newbie
Hallo liebe Forengemeinde,

jetzt nach über 2 Tagen ist es nun an der Zeit mir Hilfe zu holen weil ich mir mit dem einen und anderen Problem nicht selbst zu helfen weiß.

Es gibt ja die Cron Ordner im /etc Verzeichnis „cron.daily, cron.hourly, cron.monthly, cron.weekly“.

Dann gibt es die Globale crontab bei mir im /etc. In dieser steht nicht mehr drin als wie nachfolgend gezeigt:


Code:
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/44 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1



Es existieren keine Benutzer eigene crontabs, noch nicht. Doch jeden Tag genau um 12 Uhr Mittags, laufen alle Skripte im Ordner „Cron-Daily“ durch und ich wüsste gerne wo genau der default Wert „12 Uhr“ festgelegt wurde.

Ein weiteres Problem, der eigentliche Grund warum ich hier schreibe ist das leidige Thema Logrotate. Es arbeitet, es Rotiert und hat den Anschein das es funktionieren würde. Und doch habe ich ein Problem mit Logrotate und oder mit Apache.

Nach dem Logrotate funktioniert das Logging nicht mehr richtig. Während für den ersten Vhost weiterhin aufgezeichnet wird, verstummen die Logdateien für die restlichen Vhost’s Dateien. Erst wenn ich manuell ein Apache reload starte, wird in den Log Dateien wieder reingeschrieben. Ich weiß mir da nicht mehr weiter, vermute aber das die Abarbeitung so wie Sie mir Suse vorgegeben hat, nicht anwendbar für mehrere Vhost sind.

Vielleicht kann mir hier jemand helfen....ich danke schon mal im vorraus.

Nachfolgend nun die Ausgabe aus "logrotate -d /etc/logrotate.conf" und die Vhost aus dem Verzeichnis "logrotate.d"


Code:
logrotate -d

ww2td:~ # logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file apache2
reading config info for /var/log/apache2/access_log
reading config info for /var/log/apache2/error_log
reading config info for /var/log/apache2/suexec.log
reading config info for /var/log/apache2/ssl_request_log
reading config info for /var/log/apache2/ssl_engine_log
reading config file fetchmail
reading config info for /var/log/fetchmail
reading config file myapache2
reading config info for /srv/www/htdocs/vhost1/logs/access_log
reading config info for /srv/www/htdocs/vhost1/logs/error_log
reading config info for /srv/www/htdocs/vhost2/logs/access_log
reading config info for /srv/www/htdocs/vhost2/logs/error_log
reading config info for /srv/www/htdocs/vhost3/logs/access_log
reading config info for /srv/www/htdocs/vhost3/logs/error_log
reading config file mysql
reading config info for /var/lib/mysql/mysqld.log
reading config file net-snmp
reading config info for /var/log/net-snmpd.log
reading config file ntp
reading config info for /var/log/ntp
reading config file rsync
reading config info for /var/log/rsyncd.log
reading config file samba
reading config info for /var/log/samba/log.nmbd
reading config info for /var/log/samba/log.smbd
reading config file syslog
reading config info for /var/log/warn /var/log/messages /var/log/allmessages /var/log/localmessages /var/log/firewall /var/log/acpid /var/log/NetworkManager
reading config info for /var/log/mail /var/log/mail.info /var/log/mail.warn /var/log/mail.err
reading config info for /var/log/news/news.crit /var/log/news/news.err /var/log/news/news.notice
reading config file wtmp
reading config info for /var/log/wtmp
reading config file xdm
reading config info for /var/log/xdm.errors
reading config file xinetd
reading config info for /var/log/xinetd.log
reading config file zypper.lr
reading config info for /var/log/zypper.log
reading config file zypp-history.lr
reading config info for /var/log/zypp/history
reading config file zypp-refresh.lr
reading config info for /var/log/zypp-refresh.log
compress_prog is now /usr/bin/bzip2
compress_ext was changed to .bz2
uncompress_prog is now /usr/bin/bunzip2

Handling 27 logs

rotating pattern: /var/log/apache2/access_log  4194304 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/access_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/apache2/error_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/apache2/error_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/apache2/suexec.log  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/suexec.log
  log /var/log/apache2/suexec.log does not exist -- skipping
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/apache2/ssl_request_log  4194304 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/ssl_request_log
  log /var/log/apache2/ssl_request_log does not exist -- skipping
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/apache2/ssl_engine_log  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/apache2/ssl_engine_log
  log /var/log/apache2/ssl_engine_log does not exist -- skipping
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/fetchmail  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/fetchmail
  log does not need rotating

rotating pattern: /srv/www/htdocs/vhost1/logs/access_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /srv/www/htdocs/vhost1/logs/access_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /srv/www/htdocs/vhost1/logs/error_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /srv/www/htdocs/vhost1/logs/error_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /srv/www/htdocs/vhost2/logs/access_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /srv/www/htdocs/vhost2/logs/access_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /srv/www/htdocs/vhost2/logs/error_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /srv/www/doc/wr071ed2/logs/error_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /srv/www/htdocs/vhost3/logs/access_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /srv/www/htdocs/vhost3/logs/access_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /srv/www/htdocs/vhost3/logs/error_log  after 1 days (99 rotations)
empty log files are rotated, old logs are removed
considering log /srv/www/htdocs/vhost3/logs/error_log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/lib/mysql/mysqld.log  after 1 days (3 rotations)
empty log files are not rotated, old logs are removed
considering log /var/lib/mysql/mysqld.log
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/net-snmpd.log  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/net-snmpd.log
  log /var/log/net-snmpd.log does not exist -- skipping
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/ntp  2097152 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/ntp
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/rsyncd.log  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/rsyncd.log
  log /var/log/rsyncd.log does not exist -- skipping

rotating pattern: /var/log/samba/log.nmbd  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/samba/log.nmbd
  log /var/log/samba/log.nmbd does not exist -- skipping

rotating pattern: /var/log/samba/log.smbd  1048576 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/samba/log.smbd
  log /var/log/samba/log.smbd does not exist -- skipping

rotating pattern: /var/log/warn /var/log/messages /var/log/allmessages /var/log/localmessages /var/log/firewall /var/log/acpid /var/log/NetworkManager  4194304 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/warn
  log does not need rotating
considering log /var/log/messages
  log does not need rotating
considering log /var/log/allmessages
  log /var/log/allmessages does not exist -- skipping
considering log /var/log/localmessages
  log does not need rotating
considering log /var/log/firewall
  log does not need rotating
considering log /var/log/acpid
  log does not need rotating
considering log /var/log/NetworkManager
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/mail /var/log/mail.info /var/log/mail.warn /var/log/mail.err  4194304 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/mail
  log does not need rotating
considering log /var/log/mail.info
  log does not need rotating
considering log /var/log/mail.warn
  log does not need rotating
considering log /var/log/mail.err
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/news/news.crit /var/log/news/news.err /var/log/news/news.notice  4194304 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/news/news.crit
  log does not need rotating
considering log /var/log/news/news.err
  log does not need rotating
considering log /var/log/news/news.notice
  log does not need rotating
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/wtmp  409600 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/wtmp
  log does not need rotating

rotating pattern: /var/log/xdm.errors  4194304 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/xdm.errors
  log /var/log/xdm.errors does not exist -- skipping

rotating pattern: /var/log/xinetd.log  2097152 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/xinetd.log
  log /var/log/xinetd.log does not exist -- skipping
not running postrotate script, since no logs were rotated

rotating pattern: /var/log/zypper.log  10485760 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/zypper.log
  log does not need rotating

rotating pattern: /var/log/zypp/history  10485760 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/zypp/history
  log does not need rotating

rotating pattern: /var/log/zypp-refresh.log  10485760 bytes (99 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/zypp-refresh.log
  log /var/log/zypp-refresh.log does not exist -- skipping

Code:
logrotate Vhost 1-3
/srv/www/htdocs/vhost1/logs/access_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}

/srv/www/htdocs/vhost1/logs/error_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}

/srv/www/htdocs/vhost2/logs/access_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}

/srv/www/htdocs/vhost2/logs/error_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}

/srv/www/htdocs/vhost3/logs/access_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}

/srv/www/htdocs/vhost3/logs/error_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}

Liebe Grüße
peavey
 

revealed

Guru
Hallo,

Bitte nichts für ungut, aber hättest du dafür nicht besser einen neuen Thread mit deiner Frage aufgemacht? Könnte sein, dass dein eventuelles problem hiermit gar überhaupt nichts zu tun hat.

Gruß,

R
 
OP
P

peavey

Newbie
Da magst du sogar recht haben und wenn ich könnte, dann würde ich das hier ausschneiden, und ein neues Thema eröffnen.
Ich hoffe das ein Moderator das hier liest und ebenso handelt.

Somit hoffe ich weiter auf Hilfe zu meinen Fragen.
 

Dr. Glastonbury

Advanced Hacker
So, ja jetzt ists getrennt ;)

Zum Problem ->
eigentlich sollte ein Eintrag alla
Code:
/srv/www/htdocs/*/logs/error_log {
    compress
    daily
    dateext
    maxage 365
    rotate 99
    missingok
    create 644 root root
    postrotate
     /etc/init.d/apache2 reload
    endscript
}
für error- und access-Log reichen. Evtl. stört sich der Apache daran, dass er zu oft reloaded wird.
 
OP
P

peavey

Newbie
Hab dank erst mal das du meinen falsch platzierten Beitrag nun alleinstehend gesetzt hast.
Ich werde es mal ausprobieren, genau um 12 Uhr Mittags :)

Das war ja meine erste Frage, im gleichen Beitrag, bezugnehmend auf Cron default Wert.

Doch das was du da schreibst, ja es könnte sein und ich nehme mal an das ich dann ein reload auf den letzten Vhost setzen muss. Alternativ dachte ich schon daran alle Vhost Zeitversetzt rootieren zu lassen, von dem ich überzeugt bin das es funktionieren wird. Nur an der Umsetzung hackt es noch ein wenig, daher auch meine Frage zu cron.

Ich lass es auch wissen wie sich Apache entscheidet :)
 
OP
P

peavey

Newbie
Manchmal bin ich wirklich ein Spätzünder....na ja was soll ich sagen, nicht ohne Grund habe ich eine Zeitlang Ritalin nehmen müssen, mehr muss ich nicht sagen :)

Ne klar, so wie du das geschrieben hast, mit nem Platzhalter und einem reload für access und error, wird es hoffe ich funktionieren, im debug Mod läuft es durch.

Aber sag mal was ist denn wenn ich für jede access und error, diese jeweils dem zugehörigen Benutzer mit seinen Rechten zuordnen möchte?

Anstatt:
create 644 root root

Dann:
create 644 vhost1 vhost1

Dann komme ich gar nicht drum herum eine separate für jeden host erstellte logrotate zu nutzen, oder gibt es hier auch noch etwas was ich noch nicht weiß?

Lieben Gruß
 
OP
P

peavey

Newbie
Das Problem, der Thread gilt als gelöst. Es funktioniert so wie von dir gezeigt. Das andere Problem das ich im vorletzten Beitrag angeschnitten hatte konnte ich auch lösen indem ich das "create 644 root root bzw create 644 vhost1 vhost1" rausgenommen habe und die Rechte manuell vergeben habe. Logrotate übernimmt dann diese Werte wenn diese nicht vorgegeben werden. Das Problem mit Cron was im eigentlichen kein Probem ist, werde ich dann in einem neuen Thread erfragen.

Danke...bis bald
peavey
 

Dr. Glastonbury

Advanced Hacker
Alles klar, schön, dass es jetzt soweit funktioniert... ;)
wenn du jetzt noch ein [gelöst] in den Titel schreibst, dann bin auch ich glücklich ^^ -> einfach den ersten Post editieren
 
Oben