Back to search

logrotate

config log

Log rotation configuration

/etc/logrotate.d/{app_name}

Required Packages

sudo apt install -y logrotate

Rotation Settings

Used as config filename

Glob pattern for target log files

Useful when process still writes to recently rotated file

Rotate when file reaches this size (e.g. 100M). Overrides frequency if set.

Copy log then truncate original (for apps that can't reopen files)

Run postrotate once for all matched files

Command to run after rotation (e.g. reload service)

Generated Config — /etc/logrotate.d/{app_name}

/var/log/myapp/*.log { daily rotate 14 compress delaycompress missingok notifempty create 0640 root adm }