linux 如何定期删除指定目录中文件创建时间在3天前的文件呢?

vicepaladin 2010-04-05 03:37:07
linux 如何定期删除指定目录中文件创建时间在3天前的文件呢?
...全文
1341 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lylm 2010-04-16
  • 打赏
  • 举报
回复
find . -mtime +2 -type f -exec rm -rf {} \;
可以先用
find . -mtime +2 -type f|xargs ls -l {} \;
看一下是否是要删除的

然后放在crontab中定时执行
cjq8876 2010-04-15
  • 打赏
  • 举报
回复
find /path -mtime +2 -type f -print0 | xargs -0 rm
ForestDB 2010-04-05
  • 打赏
  • 举报
回复
find加上时间的判断选项。
Linux-Torvalds 2010-04-05
  • 打赏
  • 举报
回复
只是说一下大致思路:
ls -al,我们需要处理的是第处理的是第七个字段$7,还有最后一个字段$9,然后我们配合awk就可以实现了。当天的日期用date获取。awk具体是这样子用的。
awk "条件1{动作1},条件2{动作2},......",应该不难实现。
一品川 2010-04-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 steptodream 的回复:]
There is no "File creation time" in linux.You cat use the command "stat file" to get the last access ,modification and change time.
[/Quote]顶!
steptodream 2010-04-05
  • 打赏
  • 举报
回复
There is no "File creation time" in linux.You cat use the command "stat file" to get the last access ,modification and change time.

19,620

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧