logrotate
Publisher: Psychz Networks, October 03,2015Log-rotate is a Linux/Unix utility designed to rotate logs to prevent the local system hard-drive from being filled with old system logs.
The /etc/logrotate.conf contains the configuration files of logs to rotate, and custom logrotates users might add.
Lets say you want to have the messages logs rotate daily because it fills up your disk space.
/var/log/messages {
missingok
notifempty
size 1024M
daily
create 0644 root root
}
Here's what each line means.
missingok - do not show output error if logfile is missing
notifempty - donot rotate log file if it is empty
compress - Old versions of log files are compressed with gzip(1) by default
size - Log file is rotated only if it grow bigger than 20k
daily - ensures daily rotation
create - creates a new log file wit permissions 600 where owner and group is root
Now that you setup your logs to rotate, we'll apply changes
logrotate -f /etc/logrotate.conf
Aditional logrotate can be included, or added to the logrotate.d directory.
# RPM packages drop log rotation information into this directory include /etc/logrotate.d