If logrotate doesn’t work, than use this as a cronjob via sudo crontab -e
Put this line at the end of the file:
0 0 * * * journalctl --vacuum-size=1G >/dev/null 2>&1
Everyday the logs will be trimmed to 1GB. Usually the logs are trimmed automatically at 4GB, but sometimes this does not work
5 points
Cron is better known than a systemd timer, but you can provide an example for the timer 😃
5 points
*
Really, the correct way would be to set the limit you want for journald. Put this into /etc/systemd/journald.conf.d/00-journal-size.conf
:
[Journal]
SystemMaxUse=50M
Or something like this using a timer:
systemd-run --timer-property=OnCalender=daily $COMMAND