Skip to content

Instantly share code, notes, and snippets.

@narutaro
Last active September 20, 2015 22:32
Show Gist options
  • Save narutaro/978ad187b286ddad4cfb to your computer and use it in GitHub Desktop.
Save narutaro/978ad187b286ddad4cfb to your computer and use it in GitHub Desktop.
How to use logrotate

How to use logrotate

  1. logrotate is triggerd by cron /etc/cron.daily/logrotate
  2. Create a log rotation conf file in /etc/logrotate.d. All the files in this directory is included in /etc/logrotate.conf
  3. Let's add /etc/logrotate.d/collector for example. The contents is as follows:
/var/log/collector/log/*.log {
	daily
	missingok
	rotate 52
	compress
	delaycompress
	notifempty
	sharedscripts
}
  1. In order to test the rotation manually, type:
sudo logrotate -f /etc/logrotate.conf

The logs should be rotated

  1. Check status of the log rotation by:
cat /var/lib/logrotate/status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment