Difference between revisions of "Logrotate"

From ArchWiki
Jump to: navigation, search
(Installation: rm pacman command, see Help:Style#Package management instructions)
(Added systemd/cron functionality to the related pages list)
Line 3: Line 3:
 
{{Related articles start}}
 
{{Related articles start}}
 
{{Related|Cron}}
 
{{Related|Cron}}
 +
{{Related|systemd/cron functionality}}
 
{{Related articles end}}
 
{{Related articles end}}
  

Revision as of 09:33, 30 March 2014

From https://fedorahosted.org/logrotate/:

The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file daily, weekly, monthly or when the log file gets to a certain size.

By default, logrotate's rotation consists of renaming existing log files with a numerical suffix, then recreating the original empty log file. For example, /var/log/syslog.log is renamed /var/log/syslog.log.1. If /var/log/syslog.log.1 already exists from a previous rotation, it is first renamed /var/log/syslog.log.2. (The number of backlogs to keep can be configured.)

Installation

logrotate is available in the official repositories and is installed by default as a member of the base group.

Typically, logrotate is run via a cron job; /etc/cron.daily/logrotate is included in the package.

Configuration

The primary configuration file for logrotate is /etc/logrotate.conf; additional configuration files are included from the /etc/logrotate.d directory.

Troubleshooting

logs not being rotated

If you find that your logs aren't being rotated via the cronjob, one reason for that can be wrong user and group ownership. Both need to be root. To fix this either do:

# chown root:root /etc/logrotate.conf
# chown -R root:root /etc/logrotate.d

or, set the su variable to the user and group you desire in /etc/logrotate.conf.

exim log not rotated

If you have set the olddir variable in /etc/logrotate.conf, you will get a message such as:

error: failed to rename /var/log/exim/mainlog to /var/log/old/mainlog.1: Permission denied

To fix this, add the user exim to the group log. Then change the group of the olddir, usually /var/log/old, to log instead of the default root.

See also