I've just caught a confusing error:
rm: cannot remove `xxx/app/cache/prod': Directory not empty
which was caused by the following command:
rm -rf $cache_dir/*
where $cache_dir is defined as xxx/app/cache
So I see it like: rm removed everything in cache/prod dir, then right before it attempted to remove the cache/prod directory - another program created a file/a directory inside it thus it caused rm failure.
Is my assumption correct?
rm -ris not atomic. If you want to be sure that no more files get created in the directory while therm -rfis running, you could rename it first, then remove the renamed directory. – Johnny Oct 22 '13 at 00:19rm -rfbeing thread safe: if you run it multiple times concurrently on the same directory, the directory get deleted. This is aboutrm -rnot being atomic. – Gilles 'SO- stop being evil' Oct 22 '13 at 22:47rminvocation, we may speak about thread-safety. But anyway, it doesn't change anything – zerkms Oct 22 '13 at 23:36rm -rfis thread-safe:rm -rf & rm -rfworks as expected. The combination ofrm -rfand file creation isn't thread-safe. – Gilles 'SO- stop being evil' Oct 23 '13 at 02:32