The logrotate command is a command tool used to manage log files in the Linux system. This command can manage log files under the specified path. The default is the log file in the /var/log directory to achieve manual rotation, compression and deletion. Delete the corresponding log files to prevent the log files from being too large and causing the server C drive to become full.
The default configuration files used by the logrotate command are files in the /etc/logrotate.conf and /etc/logrotate.d/ directories.
Sentence format: logrotate parameter configuration file; parameters can be empty.
Parameter description
-d parameter: debugging function, simulates the command execution process, but will not actually execute the command;
Picture 1
-f parameter: forced rotation, this parameter is a forced startup configuration file maintenance operation;
-m parameter: This parameter is used to send text messages instead of using the /usr/bin/mail command to send the rotation results to the execution mailbox;
-s parameter: Use the status file under the specified path. This parameter is used to record the status of the next rotation;
-v parameter: displays the execution process of the command. This parameter can help users better understand the execution process of the logrotate command;
Attention
1. When using the logrotate command to start the specified configuration file, if the configuration file does not exist, or the logrotate command fails to read the linux command line startup process, an error will be reported. As shown in the figure, the specified configuration file, sentence pattern and format can be found in the /etc/logrotate.conf file.
Picture 2
2. When the logrotate command is performing a rotation operation linux command line starts the process, the corresponding target file cannot be written by other processes, otherwise the command will fail to execute.
The above is the detailed content of logrotate command: a powerful tool for managing log files in Linux systems. For more information, please follow other related articles on the PHP Chinese website!