使用find命令定期删除n天前的日志文件

日志和备份多了,硬盘不够了,所以删除之

bear@njava:/data/log$ find /data/log -mtime +3 -exec rm -rf {} \;

关于find参数-mtime,-ctime,-atime

bear@njava:~$ man find
       -mtime n
              File's data was last modified n*24 hours ago.  See the comments for -atime to understand how  rounding
              affects the interpretation of file modification times.
       -ctime n
              File's status was last changed n*24 hours ago.  See the comments for -atime to understand how rounding
              affects the interpretation of file status change times.
      -atime n
              File  was  last  accessed n*24 hours ago.  When find figures out how many 24-hour periods ago the file
              was last accessed, any fractional part is ignored, so to match -atime +1, a  file  has  to  have  been
              accessed at least two days ago.

Tags: , ,

星期六, 四月 3rd, 2010 服务器

Leave a Reply

1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr