Parameters
-? or--help online Help.
-D or--debug the instruction execution process in detail to facilitate error-making or understanding of program execution.
-F or--force forcibly initiates record file maintenance operations, even if the Logrotate directive deems it unnecessary.
The-s< state file > or--state=< state file > uses the specified state file.
The-V or--version displays the instruction execution process.
-usage Display instruction basic usage.
Parameter function
Compress the subsequent logs via gzip compression
When nocompress does not need to compress, use this parameter
Copytruncate is used for log files that are still open, and the current log is backed up and truncated
Nocopytruncate BACKUP log file but not truncate
Create Mode owner group dump file, creating a new log file using the specified file mode
Nocreate does not create a new log file
When used with delaycompress and compress, the dump log file is compressed at the next dump
Nodelaycompress overrides the Delaycompress option, and the dump is compressed at the same time.
Errors Address store error messages are sent to the specified email addresses
Ifempty even empty files are dumped, this is the default option for Logrotate.
Notifempty if it's an empty file, don't dump it.
Mail address sends the dump log files to the specified e-mail addresses
Do not send log files when Nomail dumps
The log files after the Olddir directory dump are placed in the specified directory and must be in the same file system as the current log file
The log files after the Noolddir dump are placed in the same directory as the current log file
Prerotate/endscript commands that need to be executed before dumping can be placed in this pair, and these two keywords must be in separate rows
Postrotate/endscript commands that need to be executed after the dump can be placed in this pair, and these two keywords must be in separate rows
Daily designated dump cycle for each day
Weekly specifies that the dump cycle is weekly
monthly specifies that the dump cycle is monthly
Rotate count Specifies the number of dumps before the log file is deleted, 0 means no backup, and 5 means to keep 5 backups
Tabootext [+] list lets logrotate not dump files with the specified extension, the default extension is:. Rpm-orig,. Rpmsave, V, and ~
The size of the log file is dumped only when it reaches a specified size, and the size can specify either bytes (default) and KB (Sizek) or MB (sizem).
1. Example:
[ROOT@VM etc]# Cat/etc/logrotate.d/tomcat
/opt/apache-tomcat-6.0.26/logs/catalina.out {
Daily
Dateext
Rotate 10
Missingok
Notifempty
Copytruncate
}
2, configuration instructions:
Daily: Log files are scrolled every day
Rotate: Keep the log with 5 scrolling
Notifempty: Log file is empty and does not scroll
Dateext is executed once a day, while the old log is stored in a date format "YYMMDD" instead of a simple number as a marker
Sharedscripts: Run postrotate Script
Postrotate: Start Script
Endscript: End Script
The above explanation is purely own understanding, if has the question #man logrotate