![Forrest logo](/images/logo.png)
logrotate
Logrotate is a command line tool used in Unix-like operating systems for managing log files. Its purpose is to rotate, compress, and delete log files on a regular basis to free up disk space and maintain system performance. Log files tend to grow continuously, so logrotate provides a way to manage them efficiently.
The tool is typically configured through a configuration file located in '/etc/logrotate.conf' and additional configuration files in '/etc/logrotate.d/'. These files dictate the rotation schedules, compression options, and other settings specific to each log file.
Logrotate helps prevent log files from becoming too large or overwhelming the system, which in turn ensures that important log information is consistently available. It also provides the ability to specify custom actions, such as notifying system administrators when log files are rotated or creating new log files after rotation.
Logrotate uses various criteria such as time intervals, file size, and number of log files to determine when a rotation should occur. It relies on the system's cron daemon to schedule and execute the rotation process automatically.
Overall, logrotate simplifies log file management by automating the tasks of log rotation, compression, and deletion, allowing system administrators to focus on other critical aspects of server maintenance.
List of commands for logrotate:
-
logrotate:tldr:0434e logrotate: Run using a specific command to mail reports.$ logrotate ${path-to-logrotate-conf} --mail ${-usr-bin-mail_command}try on your machineexplain this command
-
logrotate:tldr:4471c logrotate: Run without using a state (lock) file.$ logrotate ${path-to-logrotate-conf} --state /dev/nulltry on your machineexplain this command
-
logrotate:tldr:ca861 logrotate: Run and skip the state (lock) file check.$ logrotate ${path-to-logrotate-conf} --skip-state-locktry on your machineexplain this command
-
logrotate:tldr:f12ef logrotate: Tell `logrotate` to log verbose output into the log file.$ logrotate ${path-to-logrotate-conf} --log ${path-to-log_file}try on your machineexplain this command
-
logrotate:tldr:f2727 logrotate: Trigger a run manually.$ logrotate ${path-to-logrotate-conf} --forcetry on your machineexplain this command