Professional Web Applications Themes

Problems deleting a large directory - Linux / Unix Administration

Removed by Administrator...

  1. Moderated Post

    Default Problems deleting a large directory

    Removed by Administrator
    Carla Guest
    Moderated Post

  2. Moderated Post

    Default Re: Problems deleting a large directory

    Removed by Administrator
    Alexey Guest
    Moderated Post

  3. #3

    Default Re: Problems deleting a large directory

    Carla Tironi Farinati wrote: 

    With thousands of files the "rm *" will overflow the shell command
    line buffer and fail.

    With thousands of files "rm -rf mydir" probably needs to run a lot
    longer to work.

    Brute force method - This will take much longer but will run well:

    find mydir \( \! -type d \) -print | xargs rm -f
    find mydir -depth -print | xargs -1 rm -rf
    rm -rf mydir

    Since the first one will locate all non-directories and delete them
    using a legal command line length, it will run for a very long time.
    The second will run much faster. The third will run as fast as you
    can hit the return.

    Here's a bizzare case. I include it just in case the tree is so
    deep that find runs out of virtual memory remembering how deep
    it is:

    Once I had a use try to install Clearcase on a workstation they
    had the root password. (This is also a lesson why users should
    never get root). They typed wrong and somehow convinced it
    to try installing recursively. It made a chain of about 5-6 levels
    of empty directory, cd'd to the bottom and then looped to create
    the chain all over again. It started running and since the disk
    access light was one the users went home and let it run. About
    200 MB later the process finally ran out of virtual memory and failed.
    By that time it created a single chain of directories so deep no
    shell could cd that deep.

    Clearly if I wrote a loop of moving the dir one level down up one
    to flatten it the script would have run for a week. It had millions of
    inodes in the chain .. to . each link. But if I wrote a loop to "cd *"
    that would fail as well.

    The good part was that -

    while true ; do
    cd *
    done

    ran for several minutes then failed. But when i tried to type "pwd"
    it took minutes to start printing its name. Great -

    cd ..
    mv * /mountpt/lost+found
    rm -rf /mountpt/lost+found/*
    cd /mountput/lost+found
    cd *

    lather rinse repeat. Each attempt removed as many as their
    names would fit in the shell's virtual memory and also moved the
    rest up to an easily accessible location. However many dirs
    the original chain was deep, that's how many times I had to
    run that sequence. Prine pump by mooving to lost+found,
    dive as deep as possible, move up one so it fits in VM, move
    up to lost+found, attempt deletion, the "short"er chain suceeds.

    Doug Guest

  4. Moderated Post

    Default Re: Problems deleting a large directory

    Removed by Administrator
    base60 Guest
    Moderated Post

Similar Threads

  1. Large intranet directory structure for contribute use
    By yorkcollege in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: July 21st, 02:06 PM
  2. Problems deleting un-used swatches
    By Bruno_F_Moser@adobeforums.com in forum Adobe Indesign Windows
    Replies: 1
    Last Post: July 21st, 12:29 PM
  3. Very Large Artboard / Doent Size Problems and large content size
    By superfuzz_superfuzz@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 9
    Last Post: June 22nd, 06:43 PM
  4. large directory handling
    By Charles Harvey in forum PERL Beginners
    Replies: 9
    Last Post: January 6th, 04:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139