logrotate funktioniert manuell, aber nicht automatisch über cron unter Ubuntu 18.04

logrotate funktioniert manuell, aber nicht automatisch über cron unter Ubuntu 18.04

Ich habe eine Logrotate-Aufgabe, um meine Nginx-Protokolle zu rotieren. Meine Konfigurationsdatei befindet sich in /etc/logrotate.d/nginx. Wenn ich ausführe logrotate -f /etc/logrotate.d/nginx, kann es die Protokolle korrekt rotieren, was bedeutet, dass meine Konfigurationsdatei korrekt ist.

Wenn ich den Befehl in cron eingebe 0 0 * * * logrotate -f /etc/logrotate.d/nginx, werden die Protokolle nicht rotiert. Ich kann sie jedoch CRON[6006]: (root) CMD (logrotate -f /etc/logrotate.d/nginx)in /var/log/cron.log sehen, was bedeutet, dass der Befehl ausgeführt wurde. Stimmt etwas nicht?

Hier ist meine Logrotate-Konfigurationsdatei:

/var/log/nginx/access.log {
    daily
    rotate 3
    compress
    copytruncate
    dateext
}

/var/log/nginx/error.log {
    daily
    rotate 7
    compress
    copytruncate
    dateext
}

verwandte Informationen