Logrotate Weechat logs

Posted on Sun 27 December 2015 in misc

Today I noticed my Weechat logs have grown a lot! \~/.weechat/logs has grown to 360M. Obviously I need some sort of automation to take care of these logs, enter logrotate. Luckily Earnestly showed me how to use logrotate on it's own some time ago. So all I what was needed was a logrotate config file (similiar to /etc/logrotate.d/*) and a systemd user service file.

First off the \~/.local/share/logrotate.d/irc.

# weechat logrorate file

compress
missingok
notifempty
copytruncate

"~/.weechat/logs/**log" {}

The systemd service file located in \~/.config/systemd/user/weechat-rotate.service.

[Unit]
Description=Logrotate weechat's logs

[Service]
Type=simple
ExecStart=/usr/bin/logrotate -s %t/logrotate.state  %h/.local/share/logrotate.d/irc -v

[Install]
WantedBy=default.target

Logrotate will run when Systemd reaches default.target, more info about default.target can be found here. You could also use a Systemd timer to schedule the logrotate weekly or monthly.

To view log output use journalctl.

journalctl --user -f -u weechat-rotate