6

I have a systemd service configure like so:

[Unit]
Description=cprev agent
After=network.target
StartLimitIntervalSec=2

[Service]
Type=simple
Restart=always
RestartSec=15
ExecStart=/home/oleg/.local/bin/cprev-safe-start

[Install]
WantedBy=default.target

I install the service like so:

rsync "$PWD/systemd.service" "$HOME/.config/systemd/user/cprev.agent.service"
systemctl --user daemon-reload
systemctl --user enable cprev.agent.service
systemctl --user restart cprev.agent.service

I can tail the logs for my service using:

journalctl -f --user -u cprev.agent.service

my question is - do I need to manually truncate the logs for my service so they don't fill up, or does systemd manage the logs for me? If it manages for me, how does it work?

5

According to the systemd documentation, the logs kept by journald default to a size limit of 15% of disk capacity or 4GB, whichever is smaller. If /var is not mounted, not writable, or /var/log/journal does not exist, journald logs will only be stored in volatile memory (/run/log/journal.)

If your service creates log files of its own outside the systemd journal, you'll need to create a logrotate entry to manage them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.