Configuration, state, growth, and retention worksheet

Logrotate Dry-Run Simulator

Model a bounded series of logrotate runs before deploying a policy. Supply virtual configuration files and a log inventory, then inspect which files rotate, why others wait, how archives are named and compressed, and what the directory can look like after retention.

Local, inert simulation

Describe the policy and files

Include format: begin each supplied file with @@ /absolute/path. Directory includes select direct children in lexical order. Nothing is read from your real /etc.

Required columns: path,size_bytes. Optional active-log columns: modified_utc,last_rotated_utc,growth_bytes_per_day. To include an existing rotated archive, set its optional active_path to the active log it belongs to.

The teaching policy is ready.

Local and inert: configuration, paths, sizes, simulated state, reports, and shell-hook text stay in this browser tab. The tool never opens logs, reads /etc, runs a hook or compressor, changes a file, or writes a state file.

What the timeline models

The simulator expands only the virtual include files you provide, in lexical order, and carries global defaults forward to later definitions. It matches supplied active-log paths against common globs, applies hourly, daily, weekly, monthly, yearly, minute, size, minsize, and maxsize eligibility, then advances declared daily growth between runs. A missing last_rotated_utc initializes state on the first run instead of manufacturing an immediate rotation.

Archive names, compression, and retention

Numeric suffixes shift on each successful rotation; dateext, common dateformat substitutions, dateyesterday, datehourago, start, olddir, extension, and addextension affect the displayed destination. compress records compression state without inventing a compressed byte count. With delaycompress, the newest archive remains uncompressed until the following rotation. rotate and maxage remove simulated archives only when a rotation occurs.

Why overlaps and hooks need review

A broad glob can match the active file of another definition—or even previously rotated files. Matching one supplied active path from multiple definitions is reported as an error and the first definition is used only to keep the preview deterministic. Script bodies are inventoried but never executed: their exit status can prevent or alter real rotation, so a timeline containing hooks is evidence for review rather than a deployment guarantee.

Simulation boundary

This is not logrotate, a shell, or a filesystem sandbox. The model uses UTC and supplied metadata. It cannot reproduce file permissions, owners, hard links, symlinks, open descriptors, device boundaries, filesystem races, actual compression ratios, mail, shredding, service reloads, state locking, host glob behavior, distro patches, or hook failures. copytruncate is modeled as copy then zero but its documented loss window remains a warning. Confirm important policies with the same logrotate release, scheduler, configuration, state file, permissions, and disposable test logs used on the target host.

Primary reference

The supported behavior follows the upstream logrotate manual source and logrotate project. The manual documents ordered includes, default rotate 0, weekly/monthly timing, size criteria, date suffix requirements, delayed compression, retention timing, and the copytruncate loss window.

Frequently asked questions

Why did the first run only initialize state?

Without supplied prior state, the browser cannot know when the log was last rotated. Initializing at the first run avoids a false immediate rotation. Add last_rotated_utc when you need a historical eligibility decision.

Why are compressed files shown with logical bytes?

Compression depends on content, compressor, options, and version. The simulator records the original logical bytes and compression state rather than fabricating a disk size.

How do I include existing archives?

Add their paths as inventory rows and set active_path to the associated active log. Their modified_utc supplies age and ordering evidence for retention.

Can this replace logrotate --debug?

No. Use this for planning and portable what-if comparisons. Then run the target binary against isolated test files and a separate state file; note that upstream debug mode itself makes no log or state changes.

Audit a systemd timer schedule · Simulate SSH configuration · Browse systems tools