Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some directories on our production servers which I want to delete. However last time I deleted them they caused connections to the servers to start timing out as the disk IO was being swamped. Is there a command I can use to slowly delete these directories or should I write myself a shell script with some liberal sleeps?

share|improve this question
up vote 7 down vote accepted

If sleep on your system returns 0 then you can just stick it in a find command:

find ... -exec sleep 1 \; -delete
share|improve this answer
I thought about that but there are enough files that it would take at least a day at that speed. – Rory Hart Feb 21 '11 at 0:19
GNU sleep can take fractional delays, i.e. sleep 0.05. – Ignacio Vazquez-Abrams Feb 21 '11 at 0:23
You know that makes complete sense and I don't know why I assumed it didn't handle fractions! I'll blame it on Monday morning. Thanks. – Rory Hart Feb 21 '11 at 0:27
The command I used find . -depth -delete -print -exec sleep 0.05 \; – Rory Hart Feb 21 '11 at 0:36

Here is alternative

find . -type f -print0 | xargs -n 5 -0 -I {} rm {}; sleep 10

change parameters

-n 5 # this is how many files at the same time will be passed to rm command.


sleep 10 # this is how long in seconds will command sleep before next rm chunk is executed

share|improve this answer

How about:

ls | xargs -I {} -n 1 sh -c 'echo {} ; sleep 1'

Just replace echo with rm and you should be good.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.