Overview
Purgedir recursively removes files from a directory. It is optimized for fast removal of a very large number of files. To do so, the program sorts the collected files by their inode number and then unlinks them. This is supposed to minimize the time needed to locate and update inodes during the removal (at least, on ext3 and ext4 file systems).
Removing large number of files on an actively used journalling filesystem can incur high CPU load. An optional feature of purgedir allows the user to specify maximum 1-minute load average at which the program should pause in order to give the system sufficient time to update the journal and flush the data. A range of load average (MIN–MAX) can also be specified, in which case the program will pause when LA reaches MAX and resume operation when it falls below MIN. When this feature is enabled, the program will also control the number of unlinks done per time interval and will try to predict the optimal unlink rate that will keep the sytem load average below the configured maximum.
Downloads and Installation
The program can be downloaded from https://download.gnu.org.ua/release/purgedir.
As of version 1.0, no configure script is provided. The package is supposed to build cleanly on any POSIX system, the only requirement being that libc provides the function getloadavg().
Untar the archive, change to the top-level source directory and run
make
To install the program and its documentation, run
make installas root. This will install binary to /usr/bin and its manpage to /usr/share/man/man1. To select another locations, use the following make variables
- PREFIX
- Installation prefix, under which to install stuff. The default is /usr.
- BINDIR
- Directory for binary files. Default: PREFIX/bin.
- MANDIR
- Top-level directory for manual pages. Default: PREFIX/share/man.
- MAN1DIR
- Directory for section 1 manpages. Default: MANDIR/man1.
E.g. to install files under /usr/local (binary directory /usr/local/bin and manual page directory /usr/local/share/man/man1), run
make install PREFIX=/usr/local
Testing
Once compiled, run make check.
Documentation
A manpage is provided. Run man purgedir after installation. To access the manpage without installing the package, run man ./purgedir.1 from the top-level source directory.
The documentation is available online.
Development
Look for the news and updates on the project's development site.
Source repository is available here.
Bug reports
Email bug reports and suggestions to Sergey Poznyakoff.