Ich möchte alle Logdateien in einem Verzeichnis rotieren.
/etc/logrotate.d/beispiel1
/path/to/logs/*.log { su USERNAME USERGROUP weekly rotate 6 compress missingok create 660 USERNAME USERGROUP }
Führt zu folgendem Fehler:
1 2 | logrotate /etc/logrotate.d/beispiel1 error: skipping "/path/to/logs/logfile.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation. |
Nächster Versuch mit setzten des richtigen Benutzers/Gruppe
/etc/logrotate.d/beispiel2
/path/to/logs/*.log { su USERNAME USERGROUP weekly rotate 6 compress missingok create 660 USERNAME USERGROUP }
Führt zu einem anderen Fehler:
1 2 | logrotate /etc/logrotate.d/beispiel2 error: stat of /path/to/logs/logfile.log failed: Permission denied |
Zugriff auf Datei testen:
1 2 3 4 5 6 7 8 9 10 | su USERNAME $ stat /path/to/logs/logfile.log File: /path/to/logs/logfile.log Size: 1494364 Blocks: 2928 IO Block: 4096 regular file Device: 904h/2308d Inode: 8587254 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1001/ USERNAME) Gid: ( 1001/ USERGROUP) Access: 2024-04-26 16:05:41.635885068 +0200 Modify: 2020-09-11 01:13:12.825692378 +0200 Change: 2024-03-23 11:49:56.280876314 +0100 Birth: 2024-03-23 11:49:56.004878991 +0100 |
Es sieht so aus, als wenn der Zugriff auf die Datei und auf das Verzeichnis funktionieren würde. Andere Konfigurationen, die sich abgesehen vom Dateipfad nicht von beispiel2 unterscheiden, funktionieren einwandfrei. Irgendwas übersehe ich hier.