3 min read

Ubuntu 22.04 logs not rotating

I happened to look at my /var/log and discovered that it was completely full! How’d that happen?

It looks as if 22.04 broke log rotation. So the log files just keep growing until they max out the device and then stop. Yay Ubuntu!

I did a couple of things - first was to expand the size of my log device (I’m using log2ram)

# sudo emacs /etc/log2ram.conf
SIZE=120M

Next, change how much the journal keeps:

# sudo emacs /etc/systemd/jourlnald.conf
SystemMaxUse=40M

Clear out the journal:

# sudo journalctl --vacuum-size 40M

Then I went looking for the problem. Luckily, two other people had run into this and documented it on StackOverflow. I tried the same test:

# sudo logrotate /etc/logrotate.d/rsyslog --debug

and saw the same results:

error: skipping "/var/log/syslog" 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.

And then made the same change to almost everything in /etc/logrotate.d (alternatives apport bootlog btmp dpkg log2ram ppp sane-utils ufw wtmp) and to each I added to the config file (before the monthly, weekly, daily - right at the top):

# sudo emacs (one of the following: alternatives apport bootlog btmp dpkg log2ram ppp sane-utils ufw wtmp)
su syslog syslog

Then make sure they all work:

sudo logrotate /etc/logrotate.d/alternatives --debug
sudo logrotate /etc/logrotate.d/apport --debug
sudo logrotate /etc/logrotate.d/bootlog --debug
sudo logrotate /etc/logrotate.d/btmp --debug
sudo logrotate /etc/logrotate.d/dpkg --debug
sudo logrotate /etc/logrotate.d/log2ram --debug
sudo logrotate /etc/logrotate.d/ppp --debug
sudo logrotate /etc/logrotate.d/sane-utils --debug
sudo logrotate /etc/logrotate.d/ufw --debug
sudo logrotate /etc/logrotate.d/wtmp --debug

Finally, clear out all the emacs droppings because otherwise logrotate will still try to run them:

sudo rm /etc/logrotate.d/*~
sudo rm /etc/logrotate.d/\#*
sudo rm /etc/systemd/journald.conf~
sudo rm /etc/log2ram.conf~

And… that’s it, I hope!