Delete all files older than 30 days, based on file name as date

前端 未结 3 361
[愿得一人]
[愿得一人] 2020-12-11 23:10

I\'m new to bash, I have a task to delete all files older than 30 days, I can figure this out based on the files name Y_M_D.ext 2019_04_30.txt.

3条回答
  •  执笔经年
    2020-12-11 23:41

    For delete file older than X days you can use this command and schedule it in /etc/crontab

    find /PATH/TO/LOG/* -mtime +10 | xargs -d '\n' rm

    or

    find /PATH/TO/LOG/* -type f -mtime +10 -exec rm -f {} \

提交回复
热议问题