linux-implementing scheduled cleanup of logs

Source: Internet
Author: User

2 Steps for Scheduled cleanup

1. Find out the files that need to be cleaned

2, the system to increase the scheduled execution of tasks


First step , VI dellog.sh

Step Two , find the files you need to clean up

Input: Find/var/log/nginx-mtime +7-type f-name \*.log | Xargs rm-f

which

-mtime +7 to find files 7 days ago

Http://blog.sina.com.cn/s/blog_716358dc0100lj5p.html

-type F, type is file

Http://zhidao.baidu.com/link?url=KH_ Fs6kqvwbcfsxfvha2cxi-193wbkztamsvr-gmgfvc7s-8ldpndpcjk6uzj6hzxcc47nwku7rcp7datxvsvuf6z19rn18cerla5dgi9-c

-name \*.log, locate the. Log end file in the current directory

Xargs rm-f, execute the Delete command

http://czmmiao.iteye.com/blog/1949225

Step three , start a scheduled task under Linux and add the two shell scripts you just created to the program
VI root//based on the user name logged in at this time, for example, I am logged in at this time is the root user, enter the following content

0 0 * * */var/log/nginx/dellog.sh

After saving, exit, enter command Crontab root will see the/var/spool/cron/folder under the corresponding copy file root. This completes the Nginx log by day split with regular cleanup.

Http://www.cnblogs.com/peida/archive/2013/01/08/2850483.html


Reference: http://jingyan.baidu.com/article/86112f135151412736978762.html


linux-implementing scheduled cleanup of logs

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.