Understanding logrotate overview

It's no fun when log files grow out of control. In this two-part series, learn how to use logrotate to keep those logs in check.


What is logrotate?

It may surprise you to learn that logrotate is a program used to rotate logs. It's true! The system usually runs logrotate once a day, and when it runs it checks rules that can be customized on a per-directory or per-log basis.

"Log rotation" refers to the practice of archiving an application's current log, starting a fresh log, and deleting older logs. And while we're explaining things, a "log" is a file where an application stores information that might be useful to an administrator or developer - what it's been doing, what errors it's run into, that sort of thing. So logs are good, you just usually don't want to keep a ton of them around. That's where logrotate comes in.

Contents

The first part of the series introduces logrotate is and describes its general use.

• What is logrotate?

• The importance of log rotation

• How it works

• logrotate.conf

• logrotate.d

• Inside an application file

• Configuration commands

In the second part of the series we use custom virtual hosts as an example, building a configuration file for logrotate to tend to the logs for your domains. We also discuss troubleshooting and testing techniques you can use with logrotate.

• Applying knowledge

• Tying it all together: virtual host logs

• Logrotate testing flags

• How logrotate remembers

Distribution links

Links to the articles for each distribution follow.

To access the article that corresponds to the Linux distribution running on your slice, click the appropriate link below:

Ubuntu - part 1:  Understanding logrotate on Ubuntu - part 1

Ubuntu - part 2:  Understanding logrotate on Ubuntu - part 2

Debian - part 1:  Understanding logrotate on Debian - part 1

Debian - part 2:  Understanding logrotate on Debian - part 2

CentOS - part 1:  Understanding logrotate on CentOS - part 1

CentOS - part 2:  Understanding logrotate on CentOS - part 2

Fedora - part 1:  Understanding logrotate on Fedora - part 1

Fedora - part 2:  Understanding logrotate on Fedora - part 2

RHEL - part 1:  Understanding logrotate on RHEL - part 1

RHEL - part 2:  Understanding logrotate on RHEL - part 2

Gentoo - part 1:  Understanding logrotate on Gentoo - part 1

Gentoo - part 2:  Understanding logrotate on Gentoo - part 2

Arch - part 1:  Understanding logrotate on Arch - part 1

Arch - part 2:  Understanding logrotate on Arch - part 2

Further reading

Hopefully all you'll need for more information on using logrotate is its man page:

man logrotate

The man page does a very good job of laying out your options and describing how each works without getting too confusing (most of the time).

  • -- Jered
Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)