Shell Script Practice Purge Log

Source: Internet
Author: User

In the production environment log is the operation and maintenance personnel to understand and analyze the production environment first-hand information, but the content of the log information is quite large, especially in the public cloud environment running business system, the general system disk in 20g-40g, if there is no reasonable log management scheme, it is easy to appear insufficient storage space phenomenon, Summary of the following several simple methods of log processing, as their own practice notes, at the same time with everyone to exchange learning.

1, some of the number of log lines too much, the time period is longer, there is no important value information, we can delete the previous fixed line number of log files;

find/usr/app/-name filename-exec sed-i ' 1,6000000d ' {} \;

2, we can delete some of the log directly, because RM is a more dangerous command, so the general situation will not be used, so there is a compromise is to use MV replacement cut to a directory and then go to the directory to execute the delete command.

Find./-mtime +30-exec rm-f {} \; LOGPATH=/USR/TOMCATS/APACHE-TOMCAT-7.0.68-RXD/LOGS/LOGNAME1=LOCALHOST_ACCESS_LOG.*CD $logpath, Echo $logpath & &find./-mtime +30-exec mv {}/tmp/\; #find./-name *.txt-mtime +30-exec mv {}/tmp/\;cd/tmp/ && rm-f *.log && rm-f *.txtexit 0

Shell Script Practice Purge Log

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.