Create an archive:nano /etc/logrotate.d/logs-remots
nano /etc/logrotate.d/logs-remots
/var/log/remote/dns/*.log
/var/log/remote/dhcp/*.log
/var/log/remote/db/*.log
/var/log/remote/web/*.log {
daily
rotate 60
compress
delaycompress
I'm missing
notifempty
create 0640 syslog adm
sharedscripts
postrotate
systemctl reload rsyslog > /dev/null 2>&1 || true
endscript
}
CTRL + X i Save
parameter |
meaning |
---|---|
rotate 60 |
Keeps the last 60 files (60 days if daily). |
compress |
Compress with .gz after rotating. |
delaycompress |
Wait a cycle before compressing (avoids errors on recently used files) |
I’m missing |
It does not show error if a file does not exist. |
notifempty |
Does not rotate if file is empty. |
create |
Create new logs with correct permissions. |
postrotate |
Restart rsyslog after rotation (safe). |
daily |
Rotate logs daily. |