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

tägliches Logrotate

Hallo,

ich habe Logrotate so eingestellt, daß die Logdateien täglich rotiert werden. Soweit ales OK.

Code:
#cat /etc/cron.daily/logrotate
#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

Code:
#cat /etc/logrotate.d/syslog
/var/log/warn /var/log/messages /var/log/allmessages /var/log/localmessages /var/log/firewall {
    compress
    daily
    delaycompress
    rotate 7
    dateext
    maxage 30
    missingok
    notifempty
    create 640 root admin
    sharedscripts
    postrotate
        /etc/init.d/syslog reload
    endscript
}
...

Das Ergebnis ist, daß zwar täglich rotiert wird, jedoch jeden Tag exakt 15 Minuten später als am Vortag.

Wie und wo stell ich ein, daß logrotate pünktlich um Mitternacht loslegt?

Ein
Code:
crontab -l
0 0 * * * /usr/sbin/logrotate /etc/logrotate.conf
funktioniert zwar, ist aber nicht wirklich sexy.

Gruß und Dank,
Hotzi
 

panamajo

Guru
Welche Linux Dist/Version?

Unter SuSE 10.1 sollte das setzen von DAILY_TIME in /etc/sysconfig/cron helfen:
Code:
# Type:         time (eg: 14:00)
# Default:      nothing
#
# At which time cron.daily should start. Default is 15 minutes after booting
# the system. Due the cron script runs only every 15 minutes, it will only
# run on xx:00, xx:15, xx:30, xx:45, not at the accurate time you set.
DAILY_TIME="02:00"
 
Hallo,

Suse 9.3 läuft auf der Kiste.

In der /etc/sysconfig/cron gibt's da den Eintrag DAILY_TIME (noch) nicht. Kann ich den im 9.3-er Release evtl. einfügen? Mal probieren, ob's heute Nacht läuft....
 

oc2pus

Ultimate Guru
nenn das logrotate in /etc/cron.daily mal um, so das es im "Alphabet als erstes kommt", dann wird es auch als erstes script für die daily-Jobs ausgeführt.

01logrotate
02clean_catman
...

und in der /etc/crontab stellst du die daily's um auf 0:00, also diese Zeile anpassen:
Code:
14 0  * * *     root  rm -f /var/spool/cron/lastrun/cron.daily

evtl brauchen die Vorgänger immer länger ... und daher die Verschiebung.
 
oc2pus schrieb:
nenn das logrotate in /etc/cron.daily mal um, so das es im "Alphabet als erstes kommt", dann wird es auch als erstes script für die daily-Jobs ausgeführt.

01logrotate
02clean_catman
...
Hab ich gemacht. Es bringt nicht's. Es sind wieder exakt 15 Minuten Verschiebung jeden Tag.

oc2pus schrieb:
und in der /etc/crontab stellst du die daily's um auf 0:00, also diese Zeile anpassen:
Code:
14 0  * * *     root  rm -f /var/spool/cron/lastrun/cron.daily
Bei dem Eintrag wird cron nicht mal ausgeführt. Meine cron.daily schaut so aus:
Code:
cat /etc/crontab
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
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
 
Oben