Linux automatically deletes files before the specified number of days

Source: Internet
Author: User

The company has a monitoring system on-line that makes a lot of files every day, and then needs to delete files that are a few days old to ensure that the hard drive is not full of service disruption.

The statement is also very simple,

/home/monitoring/-mtime +-exec rm-rf {} \; 

-mtime-n +n by file change time to find files,-n refers to n days or less, +n refers to n days ago

The-exec:find command executes the shell command given by the parameter to the matching file. The corresponding command is in the form of ' command ' {} \;, note the space between {} and \;

And then add a line from the scheduled task to OK,

Specific find usage can baidu a bit

Find concrete Usage: http://www.cnblogs.com/wanqieddy/archive/2011/06/09/2076785.html

Linux automatically deletes files before the specified number of days

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.