Skip to content

Commit

Permalink
Merge pull request #89 from mariux64/add-logrotate
Browse files Browse the repository at this point in the history
Add logrotate configuration to rotate /var/log/messages
  • Loading branch information
donald authored May 16, 2019
2 parents b2fb618 + 026f1b1 commit 80fc7e2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,7 @@ install_data misc_systemd_units/user@.service.d/depend-on-remote-homes.conf \
mkdir -p "$DESTDIR$sysconfdir/systemd/logind.conf.d"
install_data misc_etc_files/systemd/logind.conf.d/disable_RemoveIPC.conf \
"$DESTDIR$sysconfdir/systemd/logind.conf.d/disable_RemoveIPC.conf"
install_data logrotate/logrotate.conf "$DESTDIR$sysconfdir/logrotate.conf"
install_data logrotate/logrotate.service "$DESTDIR$systemdunitdir/logrotate.service"
install_data logrotate/logrotate.timer "$DESTDIR$systemdunitdir/logrotate.timer"
exit
11 changes: 11 additions & 0 deletions logrotate/logrotate.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/var/log/messages {
dateext
dateformat .%Y-%m
dateyesterday
rotate 12
monthly
sharedscripts
postrotate
kill -HUP $(cat /var/run/rsyslogd.pid)
endscript
}
27 changes: 27 additions & 0 deletions logrotate/logrotate.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Unit]
Description=Rotate log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
RequiresMountsFor=/var/log
ConditionACPower=true

[Service]
Type=oneshot
ExecStart=/usr/sbin/logrotate -v /etc/logrotate.conf

# performance options
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7

# hardening options
# details: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
# no ProtectHome for userdir logs
# no PrivateNetwork for mail deliviery
# no ProtectKernelTunables for working SELinux with systemd older than 235
MemoryDenyWriteExecute=true
PrivateDevices=true
PrivateTmp=true
ProtectControlGroups=true
ProtectKernelModules=true
ProtectSystem=full
RestrictRealtime=true
11 changes: 11 additions & 0 deletions logrotate/logrotate.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Daily rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)

[Timer]
OnCalendar=daily
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target

0 comments on commit 80fc7e2

Please sign in to comment.