Tag: journald

  • How to configure LogRetention with journald

    Whenever you have a regular process, you definitely want to have some proper logging. But the very next thought after mentioning “logging” should be “LogRetention”. Especially when the process is executed automatically. No matter how often — as soon as the execution isn’t a one off, log rotation & log retention are a topic.

    LogRotate

    Especially on linux, it’s just so easy: use logrotate for example. Just one simple config file /settings and you’re set up with log rotation, compression and retention.

    journald & journalctl

    On my miniPC, I tried to avoid writing a lot of own log files but whent with journald and piped all logs into it. And never thought about retention. – Until today.

    I just set up another process and during testing, I noticed that I had more than 2.5gb of log files (journalctl --disk-usage) … dating back until very long. A quick check of the /etc/systemd/journald.conf confirmed that I missed some settings.

    journald has quite an elaborate set of options, just check the man page. Without big evaluation, I’ guess I’m fine with:

    Compress=yes
    SystemMaxUse=100M
    SystemMaxFileSize=5M
    MaxRetentionSec=1month

    Also, don’t forget to reload …

    sudo systemctl restart systemd-journald

    And don’t spend a second thinking about overflowing logs any more…

    Fediverse Reactions