I am deleting a directory with script it is taking 11Hour and also increase the IO on server. I am using below command, inside date directory there are hour directories, which i am deleting after archiving. Archiving is not taking long time, only "rm -rf" is taking alot of time with IOPS, please advise what should do to make it fast with less IO effect.
If it's taking 11 hours to delete a directory, it's either a very, very full directory, or rm is deleting things you didn't intend.
If it's just a very full directory, rm doesn't have a "go faster" button for that. It's the filesystem that's slow, from having far too many files piled into one folder.
I saw a link and found that we can delete multiple files with this command, is it possible we can do something like this for date directory which is also having subdirectories and we if delete directory proper with less IOPS, how, i am confuse.
Running multiple rm's at once won't make the delete happen faster because rm is not the thing being slow here.
Using other utilities to emulate rm won't make the delete happen faster because rm is not the thing being slow here.
Your disk and filesystem are performing badly because, probably, far too man files have been crammed into a single directory.
/2014-01-14/0-1/dir1
/2014-01-14/0-1/dir2
/2014-01-14/0-1/dir3
/2014-01-14/1-2/dir1
/2014-01-14/1-2/dir2
/2014-01-14/1-2/dir3
/2014-01-14/21-22/dir1
/2014-01-14/21-22/dir2
/2014-01-14/21-22/dir3
script is deleting 2014-01-14 so it is taking alot of time, total size of one day old log equal to 70GB around and each hour directory size is aound 2.3GB.
---------- Post updated at 02:39 PM ---------- Previous update was at 02:38 PM ----------
On operating system have not much space, we have only option for SAN. Is there any possibility to use ionice or nice with cron so it will take low cpu/io utilization and not create load issue on server.
That isn't relevant. You aren't getting the 'too many arguments' error. That won't solve any problems you're actually having.
I know this isn't what you want to hear, but the best way to handle this problem would have been preventatively -- by not storing your files in such an unwieldy way.
rm doesn't have a "go faster" button. To make it work faster you need faster disks.
This isn't faster than rm. rm is not "running slow" here. If you wrote a super-efficient delete program in three assembly-language instructions, it'd still be slow.
The problem is your directory. Every time you delete a file, the kernel has to update the list of files. When the list of files is really big, this can take a long time.
I know this isn't what you want to hear but there's no "delete faster" button.