find 命令删除日志文件

find ./my_dir -mtime +10 -type f -delete

EXPLANATIONS

  • ./my_dir your directory (replace with your own)
  • -mtime +10 older than 10 days
  • -type f only files
  • -delete no surprise. Remove it to test your find filter before executing the whole command

And take care that ./my_dir exists to avoid bad surprises !

https://stackoverflow.com/a/13489511/8025086

 find /mylog/path -mindepth 1 -mtime +5 -delete
  • -mindepth 1 means process all files except the command line arguments.
  • -mtime +5 will check for the files modified 5 days ago.
  • -delete will delete

https://unix.stackexchange.com/a/459997

 

posted on 2019-08-09 22:22  Go_Forward  阅读(676)  评论(0编辑  收藏  举报