Hello,
Does anyone have a recommendation on how to delete millions of files in a directory and in sub folders under that directory?
I tried using the rm -rf command but it takes FOREVER!!!
How to delete millions of files in a directory quickly?
Moderator: NorbertKrupa
-
- Intermediate
- Posts: 96
- Joined: Thu Jul 19, 2012 12:33 am
How to delete millions of files in a directory quickly?
Thanks,
Harry
Harry
- JimKnicely
- Site Admin
- Posts: 1825
- Joined: Sat Jan 21, 2012 4:58 am
- Contact:
Re: How to delete millions of files in a directory quickly?
Hi Harry,
I use the rsync trick ...
1. Create an empty directory
2. Use the rsync command in conjunction with the --delete option to synchronize the empty directory with the directory you want to empty ...
Example:
I learned this neat trick from here:
http://www.slashroot.in/which-is-the-fa ... s-in-linux
I use the rsync trick ...
1. Create an empty directory
2. Use the rsync command in conjunction with the --delete option to synchronize the empty directory with the directory you want to empty ...
Example:
Code: Select all
[dbadmin@vertica02 vertica_backups]$ pwd
/home/dbadmin/vertica_backups
[dbadmin@vertica02 vertica_backups]$ mkdir blank
[dbadmin@vertica02 vertica_backups]$ ls -lrt blank
total 0
[dbadmin@vertica02 vertica_backups]$ rsync -a --delete /home/dbadmin/vertica_backups/blank/ /home/dbadmin/vertica_backups/v_snowfall_node0001/
http://www.slashroot.in/which-is-the-fa ... s-in-linux
Jim Knicely
Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.
Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.