【问题标题】:How to find and delete 15 days older files with Cron Jobs? [closed]如何使用 Cron Jobs 查找和删除 15 天前的文件? [关闭]
【发布时间】:2015-10-03 20:31:33
【问题描述】:

我想删除超过 15 天的文件。文件目录是

/home/app_admin/files

'files'目录中有100多个文件夹,我只想删除15天以上的文件不删除文件夹。 p>

在'files'目录下,有很多文件夹如下↓↓↓

16 Jwellary Image Clipping
300 photos to be retouched
Ashraf Amin
Background removal
Background removal and retouching
Brad C
Change wording in a Photoshop file
Color Correct 123 Product Photos
cut out some high res photos

我想从这个文件夹中删除文件。

谁能帮我解决这个问题。

【问题讨论】:

  • 你试过什么?类似的任务在这个网站上已经解决了好几次了……
  • 你看过tmpwatch吗?有些轮子不需要重新发明。

标签: bash shell bin


【解决方案1】:

首先检查要删除的内容:

find path/to/basedir -mtime +15 -type f

如果输出看起来不错,则添加-delete

find path/to/basedir -mtime +15 -type f -delete

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-23
    • 2023-03-28
    • 2016-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多