find 删除日志文件

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

 

转载于:https://www.cnblogs.com/buxizhizhoum/p/11329882.html

你可能感兴趣的:(find 删除日志文件)