1.7 KiB
1.7 KiB
##Log rotate
# /etc/logrotate.d/azure_logs
/opt/AZURE/*.txt {
weekly
missingok
rotate 4
compress
delaycompress
notifempty
create 0644 root root
}
~/.azcopy/*.log {
weekly
missingok
rotate 4
compress
delaycompress
notifempty
create 0644 root root
}
Explanation:
- weekly: Rotate the logs on a weekly basis.
- missingok: If the log file is missing, go on to the next one without issuing an error message.
- rotate 4: Keep only the last 4 weeks of logs.
- compress: Compress the rotated logs using gzip.
- delaycompress: Delay compression until the next rotation cycle. This means the current log file will not be compressed immediately after rotation, but the previous log files will be.
- notifempty: Do not rotate the log if it is empty.
- create 0644 root root: Create new log files with owner
rootand grouproot, and permissions0644.
Steps to Apply the Configuration:
- Save the above configuration in
/etc/logrotate.d/azure_logs. - Ensure that the
logrotateservice is enabled and running on your system. - Test the logrotate configuration with the following command to ensure there are no syntax errors:
sudo logrotate -d /etc/logrotate.d/azure_logs
The -d option runs logrotate in debug mode, which will show you what actions would be taken without actually performing them.
- If everything looks good, you can force a rotation to test it:
sudo logrotate -f /etc/logrotate.d/azure_logs
This will rotate the logs immediately according to the specified configuration.
By following these steps, your logs in /opt/AZURE and ~/.azcopy should be rotated weekly, compressed, and kept for only the last 4 weeks.