- DietPi 8.17.2
- master
- bullseye
- Linux RPi4 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
Today I checked my logs because of a (possible) freeze of my RPi 4 (maybe it wasn’t related to the SBC at all, I couldn’t find anything in logs, maybe my wifi was just down, but this is another topic)
So instead I found some error messages, first about MariaDB and then something about logrotate
:
May 7 00:00:09 RPi4 systemd[1]: Starting Rotate log files...
May 7 00:00:09 RPi4 logrotate[432687]: error: error running shared postrotate script for '/var/log/lighttpd/*.log '
May 7 00:00:10 RPi4 systemd[1]: rsyslog.service: Sent signal SIGHUP to main process 338 (rsyslogd) on client request.
May 7 00:00:10 RPi4 systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
May 7 00:00:10 RPi4 systemd[1]: logrotate.service: Failed with result 'exit-code'.
May 7 00:00:10 RPi4 systemd[1]: Failed to start Rotate log files.
I found some related threads in other forums, for example:
https://discourse.pi-hole.net/t/logrotate-of-lighttpd-logs-failing-due-to-directory-permissions/6552
Indeed /var/log/lighttpd
is owned by www-data
:
dietpi@RPi4:~$ ls -la /var/log/lighttpd/
insgesamt 8496
drwxr-x--- 2 www-data www-data 4096 7. Mai 00:00 .
So I followed the workaround and added su www-data www-data
to my /etc/logrotate.d/lighttpd
:
/var/log/lighttpd/*.log {
su www-data www-data
weekly
missingok
rotate 12
compress
delaycompress
notifempty
sharedscripts
postrotate
if [ -x /usr/sbin/invoke-rc.d ]; then \
invoke-rc.d lighttpd reopen-logs > /dev/null 2>&1; \
else \
/etc/init.d/lighttpd reopen-logs > /dev/null 2>&1; \
fi; \
endscript
}
I ran cron.daily
manually, but I saw nothing in the syslogs.
Is it only logged when executed by systemd?
Edit:
also the last \
in the script is maybe wrong? It would not jump to endscript
?