Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete expired files regularly in Linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to delete expired files regularly in Linux, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

To delete expired files under linux, simply use the following command:

The code is as follows:

Find / var/www/-type f-mtime + 30-exec rm-f'{}\;'

The above command deletes expired files 30 days ago.

Command description:

/ var/www/ is the path to find the file.

-type f specifies that the file type is a normal file.

-mtime + 30 refers to files that were modified 30 days from now.

-exec rm-f refers to the deletion of matched files without prompting, some systems require single quotation marks and some do not.

Add the above commands to crontab and you can delete them on a regular basis.

For example, to delete at 1: 30 minutes every day, you can do this:

The code is as follows:

# crontab-e

30 1 * find / var/www/-type f-mtime + 30-exec rm-f'{}\;'

The above is how to delete expired files regularly in Linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report