Linux under Log Management tool--logrotate

Source: Internet
Author: User

Configuration
/usr/local/nginx/logs/*.log {    daily       dateext     rotate 1    olddir  /usr/local/nginx/other/logs    missingok      notifempty     compress     sharedscripts     postrotate        /bin/kill -USR1 $(cat /var/run/nginx.pid 2>/dev/null) 2>/dev/null ||:    endscript    }
    • dateext : The file suffix is a date format, that is, after the cut file is: xxx.log-20150529 (. gz), if the comment is dropped, the cut is incremented by the number, that is, the xxx.log-1 (. gz)
    • Monthly : The log file will be round by month. Other available values are ' daily ', ' weekly ' or ' yearly '.
    • rotate n : Stores n archive logs at a time. For the first N=1 Archive, the oldest archive will be deleted.
    • Compress : After a round-robin task is completed, the archived archive will be compressed using gzip . The opposite command is nocompress
    • delaycompress : Always with the compress option, The delaycompress option indicates that logrotate does not compress the most recent archive, and compression will take place during the next round-robin cycle.
    • Missingok : During the log rotation, any errors will be ignored, such as "files cannot be found".
    • notifempty : Round robin does not take place if the log file is empty. The opposite command ifempty is the default
    • prerotate/endscript : Commands that need to be executed before dumping can be placed in this pair, these two keywords must be separate rows
    • postrotate/endscript : Commands that need to be executed after the dump can be placed in this pair, these two keywords must be taken separately
    • sharedscripts : All log files are rotated once the script is completed once again
    • olddir dumps the log file into the specified directory and must be in the same file system as the current log file
Operation

The path /etc/logrotate.conf is the default configuration path, and configuration-specific log processing is typically placed /etc/logrotate.d/ next. To logrotate.conf use the include path include corresponding path in

To invoke /etc/lograte.d/ all log calls that are configured under logrotate :


To invoke for a specific configurationlogrotate


The best choice during the troubleshooting process is to use the -d option to run in a preview fashion logrotate . To validate, you can simulate the walkthrough log rotation and display its output without actually tracking any log files.


logrotate -d /etc/logrotate.d/log-file

Even if the round-robin condition is not met, we can -f force the logrotate round log file by using the option, which -v provides verbose output.

logrotate -vf /etc/logrotate.d/log-file

Reference Documentation:

Logrotate Manual
Linux log File Explorer--logrotate
Logrotate Log Management tool

Linux under Log Management tool--logrotate

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.