Last days I’ve run into an issue with customers email server. It was running very slowly so I’ve had to take a look at it.
Problem was caused by cron jobs sending error emails – 2 errors every 10 minutes.. since ’09..
This caused over 138,000(!) unwanted emails. I didn’t want to spend months at webmail deleting ~30 emails at once so I’ve quickly jump to shell and run rm *. I was quite suprised (I’m a linux noob) that it caused an Argument list too long error. find command ended up with the exactly same error message.
I thought I would try the workaround – bash script.
[~/mail]# nano remove.all #!/bin/bash for file in ./cur/* do rm $file echo removed $file done [~/mail]# chmod +x remove.all [~/mail]# ./remove.all
After about 20 minutes script has ended and it worked as it supposed to. Hooray!I know there should be much easier way like drop whole directory instead, point of this way is to try out bash loops.