![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need solution for this quickly. please quickly. | p.palakj.shah | UNIX for Dummies Questions & Answers | 5 | 04-17-2008 12:27 AM |
| Deleting Files | bc4 | UNIX for Dummies Questions & Answers | 1 | 01-25-2007 08:27 PM |
| Deleting files | BG_JrAdmin | SUN Solaris | 1 | 11-28-2006 10:17 PM |
| Deleting old files | shiroh_1982 | Shell Programming and Scripting | 2 | 06-21-2006 01:42 AM |
| Deleting the files | livetaurean19 | Shell Programming and Scripting | 0 | 06-16-2005 01:16 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
deleting 100k log files quickly
I've walked into a while loop gone bad.....which has created 100k+ log files.
Is it quicker removing the files with rm pattern* or actually removing the entire directory with rm -rf dir/ It's taking ages (hours) either way ...just curious if one is goig to be quicker than the other...or is it actaully using the same logic for deletion?
__________________
Pete |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Don't know which is faster if either - care to run your loop and time them both?
|
|
#3
|
|||
|
|||
|
Yeah sure....perhaps I could mow your lawns as well - and wash your car?
It's done now....didn't 'seem' to be quicker either way... am just curious about the logic that rm -rf uses vs rm *. Does it simply expand the 'options' much as rm * does?
__________________
Pete |
|
#4
|
||||
|
||||
|
Do I understand that you removed 100,000 files or more? If so "rm *" would not work. A whole bunch of "rm pattern*" could do it. So could "ls | xargs rm". I would go with "rm -rf /directory" just as you did. It's the least work for me.
Which is easiest on the system? The difference will be minor, it's the 100,000 unlink() system calls that take forever. But "rm -rf /directory" is one process while the other techniques are many processes. That already gives it a edge. What's more, the other techniques are creating processes with long argument lists. The shell will fork() and exec() to create a process. exec() causes a new program to overlay the program that called exec(). But first, the envirinment and the arguments must be saved so that they can be passed to the program. So you probably saved several seconds! But seriously, I appaud your curiosity. An understanding of the internal operation of unix can often be very useful. But in this case, anyway yout it, you still had to do 100,000 unlinks. |
|
#5
|
|||
|
|||
|
I did patterns..... but I like the xargs option....
So if I saved myself several seconds - I guess I spent more than that figuring out that I did! I'm guessing from your explanation then that the effort (ergo time) involved in removing one file of 1Mb is considerably less than 1,000 odd files of 1k.
__________________
Pete |
|
#6
|
||||
|
||||
|
Quote:
|
|
#7
|
||||
|
||||
|
Quote:
Or do you mean that it removes files sequentially within the directory.. in which case, sequentially or randomly, it's still removing every file in the directory, so why is that slower? |
||||
| Google The UNIX and Linux Forums |