My cron job created tens of thousands of files in the server root. I've obviously tried to remove them with
rm cron.php.*
But I've been greeted with
-bash: /bin/rm: Argument list too long
Now when there's not too many files, in the past I've used to just find the first few characters that would mach a legal number of files. I was too lazy to think about the generic solution. But this case promised I would be typing things like rm cron.php.22*, rm cron.php.23*, rm cron.php.24* etc, for quite some time. To cut the long story short, this was the solution:
find . -name 'cron.php*' -print0 | xargs -0 rm
Just in case you have trouble understanding what this does - this will reroute the find's output to xargs which will create a rm call for each file found. -print0 and -0 will make sure the command line generated by xargs doesn't fall apart if your files contain spaces.
Yours,
Tsupport.Net