On a server running Ubuntu 22.04.1 LTS, I have an application that produces many files per day, with a cron job i'm cleaning it up by removing old files. Take this as a strict setup, not possible to change it.
So, i use this in the cronjob:
nice -n 19 find PATH_2_DIR -type f -mtime +180 -print0 | xargs -0 -n 100 rm
So it deletes all files older than 180 days.The directory contains about 500'000 files that are younger than 180 days.
How can i make this command as non-impacting as possible? I'm running out of ideas.
The above command considers this:
- it uses nice to the lowest level
- it bundles 100 lines together before applying the remove command