当前位置:网站首页>Yyds dry inventory method of deleting expired documents in batch
Yyds dry inventory method of deleting expired documents in batch
2022-07-02 16:13:00 【liuzhen007】
Catalog
problem
There is a problem today , The details are as follows : Catalog /var/www/html/media/chunks/ There are many temporary files in , Need to delete , But if you delete it manually , It's going to be very slow , First , So let's see 3 What documents were there days ago .
The order is as follows :
find /var/www/html/media/chunks -mtime +3 -name "*.*"
The screenshot of the query result is as follows :

I made a rough calculation , About a thousand .
If you delete it manually , It is estimated to wait until the end of time .
solve
Since it is necessary to delete expired files according to time , Then we must know some concepts related to time . There are three information about the time of the file :atime、mtime、ctime, They mean, respectively : Last visit time (access time)、 Last changed (modify time) And the latest status change time (change time). Based on our demands , Obviously , I need to use mtime Time .
Let's take a look at the specific forms of these three times through an example :

Okay , Now that it is clear that you need to use mtime Time parameters , Let's see how to use this command parameter .
- Mode one
find . -mtime n
among ,n Is the number , It means in the current directory n Days ago “ In a day ” A file with changed content .
- Mode two
find . -mtime +n
among ,n Is the number , It means in the current directory n Days ago ( Not included n The day itself ) The file name of the changed content .
- Mode three
find . -mtime -n
among ,n Is the number , It means in the current directory n Within days ( contain n The day itself ) The file name of the changed content .
Last , Understand more vividly through a picture n The actual meaning of :

Okay , Now you can do it directly :
find /var/www/html/media/chunks -mtime +3 -name "*.*" -exec rm -Rf {} \;
The above command is used to delete all the files queried three days ago .
Let's execute the first query command , I found that the files have been deleted , The screenshot is as follows :

Author's brief introduction : Hello everyone , I am a Data-Mining(liuzhen007), Is a typical audio and video technology enthusiast , Before and after working in traditional radio and television giants and audio and video internet companies , Rich experience in audio and video live and on demand , Yes WebRTC、FFmpeg and Electron Have a very deep understanding of , official account : Play with audio and video . It's also CSDN Blogger 、 Huawei cloud sharing expert ( Co creation editor )、InfoQ Signed on , Welcome to follow me and share more dry goods !
边栏推荐
- Another graduation season
- 数据湖(十一):Iceberg表数据组织与查询
- /Bin/ld: cannot find -lxml2
- Mobile web development learning notes - Layout
- 仙人掌之歌——投石问路(3)
- JS learning notes - process control
- 数仓中的维度表与事实表
- 数据库系统概论第一章简答题-期末考得怎么样?
- Application of visualization technology in Nebula graph
- After the win10 system is upgraded for a period of time, the memory occupation is too high
猜你喜欢

Recommended practice sharing of Zhilian recruitment based on Nebula graph

潘多拉 IOT 开发板学习(RT-Thread)—— 实验2 RGB LED 实验(学习笔记)

【5G NR】RRC连接释放

Memory alignment of structure
![[5g NR] RRC connection release](/img/f3/a03f5124493b1c03e7336c55871330.png)
[5g NR] RRC connection release

Practice of constructing ten billion relationship knowledge map based on Nebula graph

mysql min() 求某条件下最小的值出现多个结果

Mobile web development learning notes - Layout

2020.4.12 byte written test questions B DP D monotone stack

Traversal before, during and after binary tree
随机推荐
源码look me
通过两级网关设计来路由服务网格流量
可视化技术在 Nebula Graph 中的应用
The light of ideal never dies
SQL modification statement
JS learning notes - process control
多数据源配置代码
Mobile web development learning notes - Layout
微信v3native支付设置的结束时间处理办法
Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
Register as a harmonios developer and install deveco studio 3.0 beta2 for harmonios
Armv8-a programming guide MMU (4)
GraphX 图计算实践之模式匹配抽取特定子图
What are the necessary functions of short video app development?
Fiddler realizes mobile packet capturing - getting started
/Bin/ld: cannot find -lpam
Another graduation season
数仓中的维度表与事实表
Kubernetes family container housekeeper pod online Q & A?
JS learning notes - first acquaintance