logrotate

From NixNet
Revision as of 03:23, 31 May 2020 by Amolith (talk | contribs) (Created page with "{{DISPLAYTITLE:logrotate}} [https://linux.die.net/man/8/logrotate logrotate] is a tool for automatically rotating server logs. It can be configured to keep them indefinitely,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

logrotate is a tool for automatically rotating server logs. It can be configured to keep them indefinitely, for a certain period, compress them after rotation, delete, shred, email them somewhere, etc. I find it incredibly useful to ensure I know what logs are kept, for how long, and that they're securely deleted.

Configuration

On a typical Debian installation, the default configs along with application-specific files are stored in /etc/logrotate.d. Read man logrotate for detailed information about what's what but here's my general template.

/path/to/log/location/*file.extension {
    rotate 7
    daily
    shred
    shredcycles 32
    missingok
}

It will rotate logs every day and keep 7 copies before shredding them. In essence, this is the same as keeping logs for a week before discarding them.