Logrotate is used to control the logging system, compress log files, delete old ones, etc.
The configuration is located at /etc/logrotate.d/ and /etc/logrotate.conf.
I will describe some parameters from the configuration:
weekly # ignore file size and rotate once a week (daily/weekly/monthly)
missingok # missing file is not an error
rotate 4 # number of compressed files to store
size=16M # maximum uncompressed file size
su USER GROUP # run logrotate as the specified user and group
compress # compress files
nocompress # do not compress files
delaycompress # compress previous file on next rotation
notifempty # don’t process empty files
create 0640 www-data adm # after rotation, create an empty file with the given rights, user, group
mail address # when finished, send the log to e-mail
nomail # Do not send old log files
start NUMBER # the number from which file numbering starts
dateext # add date instead of number to filenames
olddir PATH # put archived files in specified directory
noolddir # don’t use olddir
I will describe possible logrotate startup keys:
-d, –debug (do nothing, just test or debug (in conjunction with -v))
-f, –force (start work even if it’s not time yet)
-m, –mail=command (specify command to send email)
-s, –state=statefile (use alternate state file)
-v, –verbose (print debug information)
You can view information about log rotation with the command:
logrotate -d /etc/logrotate.conf
You can apply the changes after editing the configuration with the command:
logrotate /etc/logrotate.conf
You can start it manually using the specified configuration file like this:
logrotate -f /etc/logrotate.conf
logrotate -f /etc/logrotate.d/apache2
logrotate --force /etc/logrotate.d/apache2
See also my articles: