4 down vote accepted

This is easy enough (although note that this goes by a modification time more than 3 days ago since a creation time is only available on certain filesystems with special tools):

find /a/b/c/1 /a/b/c/2 -type f -mtime +3 #-delete

Remove the # before the -delete once you are sure that it is finding the files you want to remove.

To have it run by cron, I would probably just create an executable script (add a shebang - #!bin/sh to the top line of the file and make executable with chmod a+x), then put it in an appropriate cron directory like /etc/cron.daily or /etc/cron.weekly. Provided of course that you do not need a more specific schedule and that these directories exist on your distro.

Update

As noted below, the -delete option for find isn't very portable. A POSIX compatible approach would be:

find /a/b/c/1 /a/b/c/2 -type f -mtime +3 #-exec rm {} +

Again remove the # when you are sure you have the right files.

Update2

To quote from Stéphane Chazelas comment below:

Note that -exec rm {} + has race condition vulnerabilities which -delete (where available) doesn't have. So don't use it on directories that are writeable by others. Some finds also have a -execdir that mitigates against those vulnerabilities.

link:http://unix.stackexchange.com/questions/136804/cron-job-to-delete-files-older-than-3-days

linux delete files older than 3 days的更多相关文章

  1. Common Linux log files name and usage--reference

    reference:http://www.coolcoder.in/2013/12/common-linux-log-files-name-and-usage.html if you spend lo ...

  2. linux delete file

    今天不小心生成了这么个文件名的文件-ep-ser 然后 rm -ep-ser就删除不了,它认为-e是option 后来,用rm ./-ep-ser就顺利删除了,哈哈,教训啊

  3. Ansible 删除多个文件或目录

    翻译和转载该网页内容 http://www.mydailytutorials.com/ansible-delete-multiple-files-directories-ansible/ 背景 ans ...

  4. sql server数据同步方案-日志传送

    1 功能描述 本方案采用日志传送模式,把核心数据库(主数据库)定期同步到灾备数据库(辅助服务器)及备份库(辅助服务器,便于其他系统使用,减轻主数据压力),期间,如果发生异常导致无法同步,将以电子邮件. ...

  5. 【shell文字】mysql每日备份shell文字

    每天固定时间使用mysqldump 备份mysql数据. #!/bin/bash #每天早上4点, mysql备份数据 orangleliu #chmod 700 backup.sh #crontab ...

  6. 【shell脚本】mysql每日备份shell脚本

    每天固定时间用mysqldump 备份mysql数据. #!/bin/bash #每天早上4点, mysql备份数据 orangleliu #chmod 700 backup.sh #crontab ...

  7. postgresql backup

    #!/bin/sh # Database backup script # Backup use postgres pg_dump command: # pg_dump -U <user> ...

  8. mysql定时备份shell脚本

    #!/bin/bash #每天早上4点, mysql备份数据 # backup.sh #crontab -e # * * * /home/erya/run/moniter/mysql_backup.s ...

  9. List or delete hidden files from command prompt(CMD)

    In Windows, files/folders have a special attribute called hidden attribute. By setting this attribut ...

随机推荐

  1. Web UI Design Patterns 2014

    http://www.uxpin.com/web-design-patterns.html?utm_source=Interaction%20Design%20Best%20Practices%20V ...

  2. CROSSTOOL-NG建立交叉编译工具链

    CROSSTOOL-NG建立交叉编译工具链 因为考试和学习的原因我已经一段时间没有玩我的JZ2440,现在终于考完试了,我再次找出了我的JZ2440.我之前学习的时候使用的是韦东山老师提供的开发工具, ...

  3. 【BZOJ】【2190】【SDOI2008】仪仗队

    欧拉函数/莫比乌斯函数 Orz iwtwiioi 这个嘛……很明显在同一条线上的两个点一定是满足  x1*k=x2,y1*k=y2,(好吧这个表示方式有点傻逼,懂得就好了)那么这条线上的点只有第一个会 ...

  4. Matlab中mat2cell的使用

    怎样用mat2cell将一个100*100的矩阵分成10个10*100的矩阵? 根据帮助中 c = mat2cell(x,m,n)应该这样写 mat2cell(x,[10 10 10 10 10 10 ...

  5. Linux显示中文乱码解决方法

    vi /etc/sysconfig/i18n 将内容改为 LANG="zh_CN.GB18030" LANGUAGE="zh_CN.GB18030:zh_CN.GB231 ...

  6. 6 个基于 jQuery 的表单向导插件推荐

    表单向导可以很好地引导用户进行一步一步的操作,从而降低用户错误输入的几率.尽管互联网中有大量的类似插件,但真正好用的不多. 本文整理了6个比较优秀的表单向导插件,希望能够为你带来帮助. 1. Smar ...

  7. linux源码阅读笔记 数组定义

    在阅读linux源码的过程中遇到了下面的略显奇怪的结构体数组定义. static struct hd_struct{ long start_sect; long nr_sects; }hd[10]={ ...

  8. mac上eclipse上配置hadoop

    在mac上安装了eclipse之后,配置hadoop其实跟在linux上配置差不多,只是mac上得eclipse和界面和linux上得有点不同. 一:安装eclipse eclipse得安装比较简单, ...

  9. lintcode: search for a range 搜索区间

    题目 搜索区间 给定一个包含 n 个整数的排序数组,找出给定目标值 target 的起始和结束位置. 如果目标值不在数组中,则返回[-1, -1] 样例 给出[5, 7, 7, 8, 8, 10]和目 ...

  10. Sina App Engine(SAE)入门教程(7)- Storage使用

    参考阅读 sae storage api 文档 Storage 说明文档 Storage 大文件上传说明 storage是什么? 因为sae禁用了代码环境的本地读写,但是在网站运行的过程中,必定会出现 ...