Efficiently delete a million files on Linux servers

Efficiently delete a million files on Linux servers

Blog
It happens to the best: some script rockets to the skyline resulting in an instand system administrator headache because some folder - typically, sessions - was stuffed with millions of files. Linux is not quite happy with that, deleting the folder is not an option and the loyal "rm -rf" command decides to call it a day. To make things even worse: you want to remove only files of some days ago... what are the options? Find is you friend The Linux "find" command is a possible solution, many will go for: find /yourmagicmap/* -type f -mtime +3 -exec rm -f {} \; The command above will give a list of files older than 3 days and will pass each found file to the rm command. The rule above has…
Read More