Linux System troubleshooting log: Logrotate

Source: Internet
Author: User
Keywords System failure linux logrotate exclude log
Tags an application application configuration create disk disk space error error.log

Logrote is an application that is used to periodically rename and reuse system error log files. It guarantees that the log files will not take up too much disk space.

/etc/logrotate.conf file

It logrotate general configuration files. You can use it to set that file to be reused and how often to reuse it.

You can set the cycle parameters to be weekly or daily. In the following example, the "weekly" parameter is annotated with "#" and retains the "daily" argument. Cycle entry can also define how many copies of the log http://www.aliyun.com/zixun/aggregation/18449.html "> file backup." The following example retains 4 copies and 7 parameters are commented. Create a parameter creates a new log file after each round loop.

Therefore, in our example, all log files are backed up daily, and they are kept for 7 days. These log files will have the following file name form:

Logfilelogfile.0logfile.1logfile.2logfile.3logfile.4logfile.5logfile.6

/etc/logrotate.conf File Example

# Rotate log files weekly (weekly cycle update log file)
#weekly

# Rotate log files daily (everyday ...) )
Daily

# Keep 4 weeks worth of backlogs (keep log file backups for 4 weeks)
#rotate 4

# Keep 7 days worth of backlogs (keep log file backup within 7th)
Rotate 7

# Create new (empty) log files after the rotating old ones (when the file is recycled)
Create

/ETC/LOGROTATE.D folder

Many Linux applications that need to use syslog place their settings files in this folder so that their log files are rotated and named in their own names. You'd better check to see if all the newly installed software using syslog has a configuration file in this folder. Here are some examples that specify specific log rotation files for specific software.

Now there is a sample file in this directory that will rotate the file in the/data/backups file to the. tgz format. The parameters in this file will overwrite the settings in the/etc/logrotate.conf file. In this example, the rotation files will not be compressed, and they will be saved for 30 days without being empty. Their files will belong to root and the permissions are set to 600.

/data/backups/*.tgz {daily rotate nocompress Missingok notifempty create 0600 root root}

Note: In the Debian/ubuntu system, the/ETC/CRON.DAILY.SYSKLOGD script will read the/etc/syslog.conf file and rotate all the set log files according to it. So, for general system logs, you don't have to repeat the settings in the/ETC/LOGROTATE.D folder. It does not run for 24 hours in the/etc/cron.daily folder. In the Fedora/redhat system, this script is replaced by/etc/cron.daily/logrotate. And it does not read the syslog configuration file. So you have to set it up in/ETC/LOGROTATE.D.

Related Article

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.