-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logrotate.conf, logrotate.service and logrotate.timer to rotate and purge /var/log/messages. With this logrotate.conf, we rotate every month and keep 12 rotated files. So on Jun 1, 2019, /var/log/messages is rotated to /var/log/messages.2019-05.gz and /var/log/messages.2018-05.gz would be deleted, if it existed.
- Loading branch information
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/var/log/messages { | ||
compress | ||
dateext | ||
dateformat .%Y-%m | ||
dateyesterday | ||
rotate 12 | ||
monthly | ||
sharedscripts | ||
postrotate | ||
kill -HUP $(cat /var/run/rsyslogd.pid) | ||
endscript | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |