Friday, 19th April 2024

Comment posted How to delete million of files on busy Linux servers (Work out Argument list too long) by .

Recent comments by

Share this on:

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

No Responses to “…”

  1. korziner says:
    Firefox 11.0 Firefox 11.0 Ubuntu x64 Ubuntu x64
    Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0

    1) Why bash loop does not slow disk, compared to find? What about adding sleep to perl? 2) >keeping millions of files within the same directory is very stupid Is the following true: Even deleted files in directory reduce ext3 performance of ls. It reads inodes marked as free, which were not free. It takes time, compared to virgin inodes.

    View CommentView Comment
  2. mohan says:
    Firefox 22.0 Firefox 22.0 Windows 7 Windows 7
    Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0

    You can even use rsync command to delete millions of files in linux by syncing with a blank directory.
    The below post does a study on file deletion.
    http://www.slashroot.in/which-is-the-fastest-method-to-delete-files-in-linux

    View CommentView Comment
  3. Claus Heinrich says:
    Google Chrome 31.0.1650.63 Google Chrome 31.0.1650.63 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36

    For me the bash loop seems to work best on my production server – trying to get rid of millions of session files.
    Thanks for sharing your solutions – the find method simply couldnt do it because of the amount of files.
    I can also recommend the rsync method from mohan

    View CommentView Comment
  4. Kent Fredric says:
    Firefox 31.0 Firefox 31.0 GNU/Linux x64 GNU/Linux x64
    Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0

    Can you explain why you call stat() prior to unlink?

    # perl -e ‘for(){((stat)[9]<(unlink))}'

    This "tip" is being parroted around the internet by people who don't understand what its for, and my reasonably thorough testing indicates the stat() call slows it down.

    http://www.quora.com/Linux-why-stat+unlink-can-be-faster-than-a-single-unlink/answer/Kent-Fredric?__snids__=658761123&__nsrc__=2#

    View CommentView Comment
  5. SHASHI KANT GUPTA says:
    Google Chrome 44.0.2403.155 Google Chrome 44.0.2403.155 Windows 10 x64 Edition Windows 10 x64 Edition
    Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36

    Try “Long Path Tool ” is also useful in situations where you see these error messages: Cannot read from source file or disk, there has been a sharing violation, cannot delete file or folder, the file name you specified is not valid or too long, the source or destination file may be in use and many other file managing errors.

    View CommentView Comment
  6. frog says:
    Google Chrome 48.0.2560.0 Google Chrome 48.0.2560.0 GNU/Linux x64 GNU/Linux x64
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2560.0 Safari/537.36

    you might want to try moving all the non-related files outside the directory, and give it one shot: rm -rf DIR

    View CommentView Comment
  7. frog says:
    Google Chrome 48.0.2560.0 Google Chrome 48.0.2560.0 GNU/Linux x64 GNU/Linux x64
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2560.0 Safari/537.36

    a even better way is: write a tool in c to remove the files, you can hard-encode the direcory path in the code, and sleep periodically, to avoid stressing the server.

    View CommentView Comment
  8. Marco says:
    Firefox 56.0 Firefox 56.0 Mac OS X  10.12 Mac OS X 10.12
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0

    You're making it far too complex to yourself.
    Just execute 'rm -f [yourneeds] &' and set process priority to a lower digi, using 'nice'.

    Find the process id (pid) with 'ps' and give it a new priority:

    ps -o pid,comm,nice -p 594 # replace 594 with your process id / pid

     

    View CommentView Comment
    • Marco says:
      Firefox 56.0 Firefox 56.0 Mac OS X  10.12 Mac OS X 10.12
      Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0

      By the way, some Linux flavours also hold the 'nice' and 'renice' command. Check your MAN-pages if your version has them.

      View CommentView Comment
    • admin says:
      Firefox 52.0 Firefox 52.0 GNU/Linux x64 GNU/Linux x64
      Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

      Hey Marco,

       

      Thanks for the hint about renice and nice, that’s pretty adequate.

       

      Best,

      Georgi

      View CommentView Comment
  9. Marco says:
    Firefox 56.0 Firefox 56.0 Mac OS X  10.12 Mac OS X 10.12
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0

    You're making it far too complex to yourself.
    Just execute 'rm -f [yourneeds] &' and set process priority to a lower digi, using ''renice'.

    Find the 'nice'for your process id (pid) with 'ps' :

    ps -o pid,comm,nice -p 594 # replace 594 with your process id / pid

    Then set the new priority for the process ID:

    renice 10 -p 595 # replace 594 with your process id / pid

    It is even possible to start the process as a 'nice'process:

    nice -n 10 rm -f [yourneeds]

    and renice it afterwards using 'renice'.

     

    View CommentView Comment
  10. hip0d says:
    Google Chrome 75.0.3770.100 Google Chrome 75.0.3770.100 Windows 10 x64 Edition Windows 10 x64 Edition
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36

    If you need to delete a pattern contained in all files (e.g. delete just some of the files) you can use this command: cd /path/to/directory/; find . -type f -mtime +5 -print |grep -i 'WF_LOG_'| xargs rm -f

    View CommentView Comment