commands
logrotate — Manage text log rotation
Evaluates rotation rules when invoked. -d previews without changing logs or state; -s selects state path. Real rotation can rename, compress or delete logs and run configured scripts; only trusted private configurations should be used in a lab. Use a fresh private workspace; live operations are VM-only.
Formal Syntax & Structure
linux syntaxlinux
logrotate [OPTIONS] CONFIGParameters & Attributes
| Name | Type | Description |
|---|---|---|
| CONFIG | operand | Configuration file |
| -d | option | Debug only |
| -s | option | State path |
Return Value
exit status and output
Evaluates rotation rules when invoked. -d previews without changing logs or state; -s selects state path. Real rotation can rename, compress or delete logs and run configured scripts; only trusted private configurations should be used in a lab.
Working Example
Example Snippetlinux
{ printf '"%s/app.log" {\n' "$PWD"; cat rotate.rules; printf '}\n'; } > lab.conflogrotate -d -s "$PWD/rotate.state" lab.conf > debug.log 2>&1test ! -e rotate.state && printf 'debug complete\n'