I need to delete over 100 million small (8k-300k) files from an SMB share using Ubuntu Linux 18.04
These files are in the following folder structure:
/year/month/day/device/filename_[1...10000].jpeg
Things I've tried:
rm -rf *
- Obviously fails with a parameter overflow.
find . -type f -exec rm -f {} \;
- This would work if I had all the time in the world but is way too slow
The only way I can think of being effective is to run multiple parallel jobs each deleting a subset of the data (until I saturate the NASs ability to cope)
I'm not sure, however, how to run parallel commands from Linux command line. I could use tmux
and spawn many sessions, but that feels inelegant.
I guess I could also just put a &
at the end of bunch of command lines.
Is there a way I could write this as a shell script that would spawn multiple find & erase jobs/processes?