Skip to content
shellhacks.dev

logrotate Config Generator

Generate a logrotate rule: frequency, how many to keep, size limit, compression, date suffixes, ownership and copytruncate or a postrotate reload.

Free · No sign-up · Your inputs stay in your browser

Input

Generate a logrotate config

Output

/etc/logrotate.d/app

190 characters

Test with logrotate -d /etc/logrotate.d/app (dry run), then force one rotation with -f. copytruncate suits PHP apps that open the log per request or keep it open; it can lose lines written during the copy. A daemon that reopens its log on a signal (Nginx, via postrotate) is better served by create. For Laravel, LOG_CHANNEL=daily rotates without logrotate at all.

Runs in this browser. Nothing you paste is sent to a server.

copytruncate or create

create renames the log and creates an empty one, which works when the program can be told to reopen its files, such as Nginx with a postrotate reload. copytruncate copies the log and truncates the original in place, for programs that keep the file open and cannot reopen it; lines written during the copy can be lost. Options are documented in logrotate(8).

Laravel needs no logrotate

With LOG_CHANNEL=daily, Laravel writes one file per day and deletes those older than LOG_DAILY_DAYS. Use logrotate for the single-file channel, or for the worker and web server logs around it.

Share

Frequently asked questions

How do I test a logrotate config?
logrotate -d /etc/logrotate.d/app shows what it would do without doing it; logrotate -f forces a rotation now.
Why does logrotate say 'parent directory has insecure permissions'?
The log directory is writable by a group or others. Add su user group to the block so logrotate runs as the directory's owner.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools