LinuxCommandLibrary

logrotate

manages log files by rotating, compressing, removing, and mailing them

TLDR

Force rotation manually
$ sudo logrotate --force [/etc/logrotate.conf]
copy
Debug mode - show what would happen without making changes
$ logrotate --debug [/etc/logrotate.conf]
copy
Verbose rotation
$ sudo logrotate --verbose [/etc/logrotate.conf]
copy
Use a custom state file
$ sudo logrotate --state [/var/lib/logrotate/status] [/etc/logrotate.conf]
copy
Log verbose output to file
$ sudo logrotate --verbose --log [/var/log/logrotate.log] [/etc/logrotate.conf]
copy

SYNOPSIS

logrotate [options] configfile_

DESCRIPTION

logrotate manages log files by rotating, compressing, removing, and mailing them. It prevents logs from consuming excessive disk space and is typically run daily via cron.

PARAMETERS

-f, --force

Force rotation even if conditions are not met
-d, --debug
Debug mode; show what would happen without making changes
-v, --verbose
Verbose output
-s, --state FILE
Use alternate state file (default: /var/lib/logrotate/status)
-l, --log FILE
Log verbose output to file
--mail COMMAND
Use specified command to mail logs

CAVEATS

Configuration files in /etc/logrotate.d/ are included by the main config. The state file tracks when each log was last rotated. Typically run daily via cron or systemd timer.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard