Getting started with Linux: logrotate in Linux

Source: Internet
Author: User

Getting started with Linux: logrotate in Linux

The logrotae program is a log file management tool used to delete old log files and create new log files. We call it "dump ". We can dump the logs based on the log file size or the number of days. This process is generally executed by the cron program. The logrotate program can also be used to compress log files and send log files to the specified email address.

The logrotate configuration file is/etc/logrotate. conf. Its main parameters are as follows:

Compress indicates that logs after dumping are compressed using gzip

Nocompress indicates no compression is required

Copytruncate indicates that the log file is still open, and the current log is backed up and truncated.

Nocopytruncate backs up log files but does not truncate

Create mode owner group dump file, create a new log file using the specified file mode

Nocreate does not create a new Log File

Delaycompress and compress are used together to compress the log files dumped to the next dump.

Nodelaycompress overwrites the delaycompress option to compress the dump at the same time

The error message sent when errors address is dumped to the specified email address

Ifempty dumps even empty files. This is the default logrotate option.

Notifempty is not dumped if it is an empty file

Mail address sends the dumped log file to the specified E-mail address

Do not send log files when nomail dump

The log file after the olddir directory is dumped is placed in the specified directory and must be in the same file system as the current log file.

The log file after noolddir dumping and the current log file are placed in the same directory

Prerotate/endscript can put this pair of commands that need to be executed before dumping. These two keywords must be in a separate line.

Postrotae/endscript can be placed into this pair of commands to be executed after the dump. These two keywords must be entered in a separate line.

Daily indicates that the dump cycle is daily.

Weekly indicates that the dump cycle is weekly.

Monthly specifies the dump cycle as per month

Rotate count indicates the number of dump times before the log file is deleted. 0 indicates no backup, and 6 indicates that 6 backups are retained.

Tabootext [+] list to prevent logrotate from dumping files with the specified extension. The default extension is. rpm-orig,. rpmsave, v, and ~

The default logrotate configuration file is/etc/logrotate. conf.

Logrotate configuration and understanding in Linux

Use logrotate in Linux to manage log files cyclically

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.