Setting Cron job to delete file after 24 hours

前端 未结 4 1564
再見小時候
再見小時候 2021-02-10 09:22

I read all the related questions and was unable to understand them. I am using Plesk CPanel to set cron job as it was advised by everyone.

I want to delete all files fro

4条回答
  •  青春惊慌失措
    2021-02-10 09:41

    To optimize MrCleanX' solution a bit, use xargs:

    find /some/path -type f -mtime +7 -print0 | xargs -0 --no-run-if-empty rm
    

    Instead of calling rm for each file to delete, xargs packs many files together to a single call to rm

    The -print0 and -0 stuff is to make both find and xargs using NULL terminated strings, which is necessary to handle file names with space and other interesting chars in their names.

提交回复
热议问题