Get Pro License

Linux Logrotate Config Generator

Create safe, production-ready log rotation policies for Nginx, Apache, or custom Linux applications to prevent full disks.

Target specific files or use *.log to match all logs in a folder.
How often to trigger a rotation cycle.
Force rotation early if file exceeds this size.
Oldest files are deleted after this count.
Ownership of the new empty log file created after rotation.
A command to run after rotation. Usually reloads the service so it writes to the new file.

        

Log Rotation Explained

🚫 The Problem: The "Full Disk" Crash

Applications write logs continuously. If left unchecked, a single access.log can grow to 50GB+ over months. Eventually, your server runs out of disk space, the database locks up, and your application crashes. You cannot simply delete the file while the app is running, or logging will stop completely.

✅ The Solution: Automated Hygiene

Logrotate is a Linux system utility that runs in the background. It automatically Renames your current log file, Creates a fresh empty one for the app to write to, Compresses the old data to save space, and Deletes files that are too old.

How Rotation Works (Visualized)

Current
app.log
(Writing)
Yesterday
app.log.1
(Renamed)
Older
app.log.2.gz
(Compressed)
Oldest
app.log.14.gz
(Expired)
Deleted
Cleanup

Installation Guide

1. Create a file in the logrotate configuration directory:

sudo nano /etc/logrotate.d/myapp

2. Paste the code generated above and save.

3. Test for syntax errors (Dry Run):

sudo logrotate -d /etc/logrotate.d/myapp