log rotation

RobFantini

Famous Member
May 24, 2012
2,084
116
133
Boston,Mass
For some reason on PVE and Nextcloud and other systems log rotation came to a halt in November. /var/log had over 7G . /var/log/journal had 4G

i think it has something to do with a conflict with rsyslog and systemd journal stuff. will check later

to fix edit
/etc/cron.daily/logrotate

Code:
# skip in favour of systemd timer
#
# 2023-01-12  logs had not been rotated in a month
#   i did not see a systemd log rotate timer
#   so commented this out so it will run here
#
# 2023-01-13 more detail.  i had started logrotate.timer  . on reboot was dead:
# root@nextcloud:[~]:#  systemctl status logrotate.timer   
#● logrotate.timer - Daily rotation of log files
#     Loaded: loaded (/lib/systemd/system/logrotate.timer; disabled; vendor preset: enabled)
#     Active: inactive (dead)

###    COMMENT OUT THESE 3 LINES  so that logrotate will work from good old regular cron.
#if [ -d /run/systemd/system ]; then
#    exit 0
#fi
# this cronjob persists removals (but not purges)
if [ ! -x /usr/sbin/logrotate ]; then
    exit 0
fi

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